Skip to content

Commit

Permalink
add more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Sep 16, 2023
1 parent ffa82dc commit 9866ffc
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
4 changes: 1 addition & 3 deletions docs/data/joy/components/menu/MenuListComposition.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export default function MenuListComposition() {
if (event.key === 'Tab') {
setOpen(false);
} else if (event.key === 'Escape') {
if (buttonRef.current) {
buttonRef.current?.focus();
}
buttonRef.current.focus();
setOpen(false);
}
};
Expand Down
8 changes: 3 additions & 5 deletions docs/data/joy/components/menu/MenuListComposition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const Popup = styled(Popper)({
zIndex: 1000,
});

export default function MenuListComposition(): JSX.Element {
const buttonRef = React.useRef<HTMLButtonElement | null>(null);
export default function MenuListComposition() {
const buttonRef = React.useRef<HTMLButtonElement>(null);
const [open, setOpen] = React.useState(false);

const handleClose = () => {
Expand All @@ -22,9 +22,7 @@ export default function MenuListComposition(): JSX.Element {
if (event.key === 'Tab') {
setOpen(false);
} else if (event.key === 'Escape') {
if (buttonRef.current) {
buttonRef.current?.focus();
}
buttonRef.current!.focus();
setOpen(false);
}
};
Expand Down
4 changes: 2 additions & 2 deletions docs/src/components/header/HeaderNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ export default function HeaderNavBar() {
const [subMenuOpen, setSubMenuOpen] = React.useState<null | 'products' | 'docs'>(null);
const [subMenuIndex, setSubMenuIndex] = React.useState<number | null>(null);
const navRef = React.useRef<HTMLUListElement | null>(null);
const productsMenuRef = React.useRef<HTMLButtonElement | null>(null);
const docsMenuRef = React.useRef<HTMLButtonElement | null>(null);
const productsMenuRef = React.useRef<HTMLButtonElement>(null);
const docsMenuRef = React.useRef<HTMLButtonElement>(null);
React.useEffect(() => {
if (typeof subMenuIndex === 'number') {
document.getElementById(PRODUCT_IDS[subMenuIndex])?.focus();
Expand Down
4 changes: 2 additions & 2 deletions docs/src/components/header/HeaderNavDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default function HeaderNavDropdown() {
const [open, setOpen] = React.useState(false);
const [productsOpen, setProductsOpen] = React.useState(true);
const [docsOpen, setDocsOpen] = React.useState(false);
const hambugerRef = React.useRef<HTMLButtonElement | null>(null);
const hambugerRef = React.useRef<HTMLButtonElement>(null);
return (
<React.Fragment>
<IconButton
Expand Down Expand Up @@ -150,7 +150,7 @@ export default function HeaderNavDropdown() {
</IconButton>
<ClickAwayListener
onClickAway={(event) => {
if (hambugerRef.current && !hambugerRef.current.contains(event.target as Node)) {
if (hambugerRef.current!.contains(event.target as Node)) {
setOpen(false);
}
}}
Expand Down
2 changes: 1 addition & 1 deletion examples/joy-ui-vite-ts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import App from './App';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
Expand Down
2 changes: 1 addition & 1 deletion examples/material-ui-vite-ts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CssBaseline } from '@mui/material';
import theme from './theme';
import App from './App';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ThemeProvider theme={theme}>
<CssBaseline />
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useSelect/useSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function useSelect<OptionValue, Multiple extends boolean = false>(
return;
}

const listboxClientRect = (listboxRef.current as HTMLElement).getBoundingClientRect();
const listboxClientRect = listboxRef.current.getBoundingClientRect();
const optionClientRect = optionRef.current.getBoundingClientRect();

if (optionClientRect.top < listboxClientRect.top) {
Expand Down

0 comments on commit 9866ffc

Please sign in to comment.