fix: preserve mobile section focus

This commit is contained in:
ajnart committed 2026-07-28 19:39:13 +02:00
1 parent 6dbfbb1417
commit 7ce1081161
1 file changed
+5 -3
@@ -269,6 +269,7 @@ const MobileMoreMenu = ({ showSettings }: { showSettings: boolean }) => {
const tProfile = useScopedI18n("common.userAvatar.menu");
const reduceMotion = useReducedMotion();
const [opened, disclosure] = useDisclosure(false);
const moreTriggerRef = useRef<HTMLButtonElement>(null);
const pendingSectionAnchorId = useRef<string | null>(null);
const desktopLayout = getDesktopLayout(board);
const sections = useMemo(
@@ -284,14 +285,14 @@ const MobileMoreMenu = ({ showSettings }: { showSettings: boolean }) => {
const focusPendingSection = () => {
const anchorId = pendingSectionAnchorId.current;
pendingSectionAnchorId.current = null;
if (!anchorId) return;
if (anchorId && focusMobileBoardSection({ anchorId, reduceMotion })) return;
focusMobileBoardSection({ anchorId, reduceMotion });
moreTriggerRef.current?.focus({ preventScroll: true });
};
return (
<>
<HeaderButton onClick={disclosure.open} aria-label={t("board.mobile.more")}>
<HeaderButton ref={moreTriggerRef} onClick={disclosure.open} aria-label={t("board.mobile.more")}>
<IconDotsVertical stroke={1.5} />
</HeaderButton>
<Drawer
@@ -302,6 +303,7 @@ const MobileMoreMenu = ({ showSettings }: { showSettings: boolean }) => {
size="auto"
padding="md"
overlayProps={{ backgroundOpacity: 0.45, blur: 2 }}
returnFocus={false}
onExitTransitionEnd={focusPendingSection}
styles={{
content: {