fix(mobile-menu): focus the sheet panel instead of the Home link so its text stops rolling on open

This commit is contained in:
dong.nguyen committed 2026-10-17 15:11:21 +07:00
1 parent 6cd665960a
commit 75ebf65e92
5 files changed
+28 -20

No files matched your search

+4 -3
View File
@@ -19,22 +19,24 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
const { resolvedTheme, setTheme, palette, setPalette } = useTheme()
const location = useLocation()
const reduceMotion = useReducedMotion()
const firstLinkRef = useRef<HTMLAnchorElement>(null)
const sheetRef = useRef<HTMLDivElement>(null)
return (
<AnimatePresence>
{open && (
<motion.div
ref={sheetRef}
id="mobile-menu"
className="mobile-menu"
role="dialog"
aria-modal="true"
tabIndex={-1}
aria-label={strings.nav.menuAria[lang]}
initial={{ opacity: 0, y: -12 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -12 }}
transition={{ duration: 0.22, ease: [0.25, 0.1, 0.25, 1] }}
onAnimationComplete={() => firstLinkRef.current?.focus()}
onAnimationComplete={() => sheetRef.current?.focus()}
>
<div className="mobile-menu-inner">
<nav className="mobile-menu-group" aria-label={strings.nav.groupMenu[lang]}>
@@ -52,7 +54,6 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
>
<RollingTextLink
to={path}
ref={index === 0 ? firstLinkRef : undefined}
ariaCurrent={active ? 'page' : undefined}
className={active ? 'mobile-menu-link active' : 'mobile-menu-link'}
onClick={onClose}