chore: dont autofocus menu items on mobile
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
import { KeyboardKey } from '@standardnotes/ui-services'
|
import { KeyboardKey } from '@standardnotes/ui-services'
|
||||||
import { useListKeyboardNavigation } from '@/Hooks/useListKeyboardNavigation'
|
import { useListKeyboardNavigation } from '@/Hooks/useListKeyboardNavigation'
|
||||||
import { mergeRefs } from '@/Hooks/mergeRefs'
|
import { mergeRefs } from '@/Hooks/mergeRefs'
|
||||||
|
import { MutuallyExclusiveMediaQueryBreakpoints, useMediaQuery } from '@/Hooks/useMediaQuery'
|
||||||
|
|
||||||
type MenuProps = {
|
type MenuProps = {
|
||||||
className?: string
|
className?: string
|
||||||
@@ -51,7 +52,13 @@ const Menu = forwardRef(
|
|||||||
[closeMenu, onKeyDown],
|
[closeMenu, onKeyDown],
|
||||||
)
|
)
|
||||||
|
|
||||||
const { setInitialFocus } = useListKeyboardNavigation(menuElementRef, initialFocus, shouldAutoFocus)
|
const isMobileScreen = useMediaQuery(MutuallyExclusiveMediaQueryBreakpoints.sm)
|
||||||
|
|
||||||
|
const { setInitialFocus } = useListKeyboardNavigation(
|
||||||
|
menuElementRef,
|
||||||
|
initialFocus,
|
||||||
|
isMobileScreen ? false : shouldAutoFocus,
|
||||||
|
)
|
||||||
|
|
||||||
useImperativeHandle(forwardedRef, () => ({
|
useImperativeHandle(forwardedRef, () => ({
|
||||||
focus: () => {
|
focus: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user