Skip to content

Commit 1882c3a

Browse files
authored
Merge pull request #109 from kube-js/develop
fix: fixed popper z-index issue
2 parents 524d82d + e4b012c commit 1882c3a

File tree

8 files changed

+51
-15
lines changed

8 files changed

+51
-15
lines changed

assets/jscpd-badge.svg

Lines changed: 2 additions & 2 deletions
Loading

k8s/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
description: A Helm chart for kube-ts-react-client
33
name: kube-ts-react-client
44
version: 1.0.0
5-
appVersion: 1.5.23
5+
appVersion: 1.5.25
66
home: https://cloud.docker.com/u/kubejs/repository/docker/kubejs/kube-ts-react-client
77
icon: https://avatars2.githubusercontent.com/u/47761918?s=200&v=4
88
sources:

k8s/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replicaCount: 2
66

77
image:
88
repository: kubejs/kube-ts-react-client
9-
tag: 1.5.23
9+
tag: 1.5.25
1010
pullPolicy: Always
1111
containerPort: 80
1212

src/app.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import AuthenticatedRoute from './components/Auth/AuthenticatedRoute';
55
import UnauthenticatedRoute from './components/Auth/UnauthenticatedRoute';
66
import CourseView from './components/CourseView';
77
import ErrorBoundary from './components/ErrorBoundaries/Page/index';
8+
import InstructorView from './components/InstructorView';
89
import Layout from './components/Layout';
910
import {
1011
COURSE_VIEW,
1112
DASHBOARD,
13+
INSTRUCTOR_VIEW,
1214
LOGIN,
1315
REGISTER,
1416
REMIND_PASSWORD,
@@ -41,6 +43,7 @@ const App = () => (
4143
<Route exact path={COURSE_VIEW} component={CourseView} />
4244
<Route exact path={RESET_PASSWORD} component={ResetPassword} />
4345
<Route exact path={VERIFY} component={VerifyAccount} />
46+
<Route path={INSTRUCTOR_VIEW} component={InstructorView} />
4447

4548
<UnauthenticatedRoute
4649
exact

src/atoms/Autocomplete/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CloseIcon from '@material-ui/icons/Close';
77
import SearchIcon from '@material-ui/icons/Search';
88
import Downshift from 'downshift';
99
import _isNil from 'ramda/src/isNil';
10-
import React, { useState } from 'react';
10+
import React, { useRef, useState } from 'react';
1111
import { useDispatch, useSelector } from 'react-redux';
1212
import { useHistory } from 'react-router-dom';
1313
import { autocompleteRequested } from '../../redux/autocomplete/actionCreators';
@@ -111,13 +111,14 @@ interface Options {
111111
readonly type: AutocompleteType;
112112
}
113113

114+
const POPPER_OFFSET = 4;
115+
114116
const Autocomplete = ({ id, type }: Options) => {
115117
const classes = useStyles();
116118

117119
const additionalOptions = autocompleteOptions[type];
118120

119-
// TODO: explore useRef, fix popper width
120-
let popperNode: any;
121+
const popperNode: any = useRef({});
121122

122123
const [value, setValue] = useState('');
123124
const history = useHistory();
@@ -141,7 +142,8 @@ const Autocomplete = ({ id, type }: Options) => {
141142
const link =
142143
item.type === 'course'
143144
? `/courses/${item.slug}`
144-
: `/instructors/${item.email}`;
145+
// TODO: create username property as uniq db field
146+
: `/instructors/${String(item.firstName + item.lastName).toLowerCase()}`;
145147
setValue('');
146148
history.push(link);
147149
} else if (changes.hasOwnProperty('inputValue')) {
@@ -179,16 +181,14 @@ const Autocomplete = ({ id, type }: Options) => {
179181
classes,
180182
fullWidth: true,
181183
inputProps,
182-
ref: (node: any) => {
183-
popperNode = node;
184-
},
184+
ref: popperNode
185185
})}
186186
{String(inputProps.value).length > 0 && (
187187
<div className={[classes.icon, classes.closeIcon].join(' ')}>
188188
<CloseIcon onClick={clearSelection as any} />
189189
</div>
190190
)}
191-
<Popper open={isOpen} anchorEl={popperNode}>
191+
<Popper open={isOpen} anchorEl={popperNode.current} disablePortal>
192192
<div
193193
{...(isOpen
194194
? getMenuProps({}, { suppressRefError: true })
@@ -197,8 +197,8 @@ const Autocomplete = ({ id, type }: Options) => {
197197
<Paper
198198
square
199199
style={{
200-
marginTop: 8,
201-
width: popperNode ? popperNode.clientWidth : undefined,
200+
marginTop: '4px',
201+
width: popperNode.current && popperNode.current.clientWidth ? popperNode.current.clientWidth - POPPER_OFFSET : undefined,
202202
}}
203203
>
204204
{results.map((suggestion: any, index: number) =>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import { Container } from '@material-ui/core';
3+
import React, { memo } from 'react';
4+
import { useParams } from 'react-router';
5+
import useStyles from './styles';
6+
7+
const InstructorView = () => {
8+
const classes = useStyles();
9+
10+
const params = useParams<{username?: string}>();
11+
12+
const username = params.username !== undefined ? params.username : 'username';
13+
14+
return (
15+
<div className={classes.root}>
16+
<Container component="main" maxWidth="lg">
17+
<h2>{username}</h2>
18+
</Container>
19+
</div>
20+
);
21+
};
22+
23+
export default memo(InstructorView);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { makeStyles } from '@material-ui/core/styles';
2+
3+
const useStyles = makeStyles(() => ({
4+
root: {
5+
flexGrow: 1,
6+
},
7+
}));
8+
9+
export default useStyles;

src/constants/routes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export const RESET_PASSWORD = '/reset-password';
55
export const VERIFY = '/verify';
66
export const LOGIN = '/login';
77
export const DASHBOARD = '/dashboard';
8-
export const COURSE_VIEW = '/courses/:courseSlug'
8+
export const COURSE_VIEW = '/courses/:courseSlug';
9+
export const INSTRUCTOR_VIEW = '/instructors/:username';

0 commit comments

Comments
 (0)