Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 4cda251

Browse files
boilundsteabert
authored andcommitted
chore: fix lint and test error
1 parent bd914c6 commit 4cda251

File tree

2 files changed

+69
-60
lines changed

2 files changed

+69
-60
lines changed

packages/core/src/Menu/BaseMenu.tsx

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -391,63 +391,64 @@ export interface BaseItemWithSubmenuProps
391391
readonly hideSubmenu: VoidFunction
392392
}
393393

394-
const BaseItemWithSubmenu: React.FunctionComponent<BaseItemWithSubmenuProps> =
395-
({
396-
component,
397-
submenuComponents,
398-
disabled,
399-
keyboardSelect,
400-
align,
401-
submenuVisible,
402-
submenuArrowIndex,
403-
hideAndBlurMenu,
404-
hideSubmenu,
405-
}) => {
406-
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
394+
const BaseItemWithSubmenu: React.FunctionComponent<
395+
BaseItemWithSubmenuProps
396+
> = ({
397+
component,
398+
submenuComponents,
399+
disabled,
400+
keyboardSelect,
401+
align,
402+
submenuVisible,
403+
submenuArrowIndex,
404+
hideAndBlurMenu,
405+
hideSubmenu,
406+
}) => {
407+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
407408

408-
const [visible, show, hide] = useBoolean(false)
409-
const [debouncedVisible, setDebouncedVisible] = useState(visible)
409+
const [visible, show, hide] = useBoolean(false)
410+
const [debouncedVisible, setDebouncedVisible] = useState(visible)
410411

411-
useEffect(() => {
412-
const delayVisible = () => setDebouncedVisible(visible)
413-
const delayed = setTimeout(delayVisible, SUBMENU_DELAY_MS)
414-
return () => {
415-
clearTimeout(delayed)
416-
}
417-
}, [visible])
412+
useEffect(() => {
413+
const delayVisible = () => setDebouncedVisible(visible)
414+
const delayed = setTimeout(delayVisible, SUBMENU_DELAY_MS)
415+
return () => {
416+
clearTimeout(delayed)
417+
}
418+
}, [visible])
418419

419-
const preventMenuBlur = useCallback<PointerEventHandler>(e => {
420-
// Prevent the menu from losing focus when clicking down on an item.
421-
e.preventDefault()
422-
}, [])
420+
const preventMenuBlur = useCallback<PointerEventHandler>(e => {
421+
// Prevent the menu from losing focus when clicking down on an item.
422+
e.preventDefault()
423+
}, [])
423424

424-
return (
425-
<>
426-
<BaseMenuItem
427-
ref={setAnchorEl}
425+
return (
426+
<>
427+
<BaseMenuItem
428+
ref={setAnchorEl}
429+
disabled={disabled}
430+
keyboardSelect={keyboardSelect}
431+
onPointerDown={preventMenuBlur}
432+
onPointerOver={show}
433+
onPointerOut={hide}
434+
>
435+
{component}
436+
</BaseMenuItem>
437+
{submenuComponents !== undefined && (
438+
<Submenu
439+
visible={submenuVisible || debouncedVisible}
440+
submenuComponents={submenuComponents}
441+
anchorEl={anchorEl}
428442
disabled={disabled}
429-
keyboardSelect={keyboardSelect}
430-
onPointerDown={preventMenuBlur}
431-
onPointerOver={show}
432-
onPointerOut={hide}
433-
>
434-
{component}
435-
</BaseMenuItem>
436-
{submenuComponents !== undefined && (
437-
<Submenu
438-
visible={submenuVisible || debouncedVisible}
439-
submenuComponents={submenuComponents}
440-
anchorEl={anchorEl}
441-
disabled={disabled}
442-
align={align}
443-
arrowIndex={submenuArrowIndex}
444-
hideAndBlurMenu={hideAndBlurMenu}
445-
hideSubmenu={hideSubmenu}
446-
/>
447-
)}
448-
</>
449-
)
450-
}
443+
align={align}
444+
arrowIndex={submenuArrowIndex}
445+
hideAndBlurMenu={hideAndBlurMenu}
446+
hideSubmenu={hideSubmenu}
447+
/>
448+
)}
449+
</>
450+
)
451+
}
451452

452453
export interface BaseItemProps {
453454
readonly component: ReactNode

packages/core/src/Menu/__snapshots__/index.test.tsx.snap

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,13 @@ exports[`Menus with submenu Menu (default) 1`] = `
10151015
border: 2px solid transparent;
10161016
}
10171017
1018-
.c3:hover .c4 {
1018+
.c3:hover .c4,
1019+
.c3:focus-within .c4 {
10191020
border: 0 solid transparent;
10201021
}
10211022
1022-
.c3:hover .c8 {
1023+
.c3:hover .c8,
1024+
.c3:focus-within .c8 {
10231025
background-color: rgba(204,204,204,0.16);
10241026
-webkit-transform: scale(1);
10251027
-ms-transform: scale(1);
@@ -1238,11 +1240,13 @@ exports[`Menus with submenu Menu (disabled) 1`] = `
12381240
border: 2px solid transparent;
12391241
}
12401242
1241-
.c3:hover .c4 {
1243+
.c3:hover .c4,
1244+
.c3:focus-within .c4 {
12421245
border: 0 solid transparent;
12431246
}
12441247
1245-
.c3:hover .c8 {
1248+
.c3:hover .c8,
1249+
.c3:focus-within .c8 {
12461250
background-color: rgba(204,204,204,0.16);
12471251
-webkit-transform: scale(1);
12481252
-ms-transform: scale(1);
@@ -1457,11 +1461,13 @@ exports[`Menus with submenu Menu (left) 1`] = `
14571461
border: 2px solid transparent;
14581462
}
14591463
1460-
.c3:hover .c4 {
1464+
.c3:hover .c4,
1465+
.c3:focus-within .c4 {
14611466
border: 0 solid transparent;
14621467
}
14631468
1464-
.c3:hover .c8 {
1469+
.c3:hover .c8,
1470+
.c3:focus-within .c8 {
14651471
background-color: rgba(204,204,204,0.16);
14661472
-webkit-transform: scale(1);
14671473
-ms-transform: scale(1);
@@ -1676,11 +1682,13 @@ exports[`Menus with submenu Menu (right) 1`] = `
16761682
border: 2px solid transparent;
16771683
}
16781684
1679-
.c3:hover .c4 {
1685+
.c3:hover .c4,
1686+
.c3:focus-within .c4 {
16801687
border: 0 solid transparent;
16811688
}
16821689
1683-
.c3:hover .c8 {
1690+
.c3:hover .c8,
1691+
.c3:focus-within .c8 {
16841692
background-color: rgba(204,204,204,0.16);
16851693
-webkit-transform: scale(1);
16861694
-ms-transform: scale(1);

0 commit comments

Comments
 (0)