Skip to content

Commit bffefb9

Browse files
committed
fix: preserve mobile section focus
1 parent 2d902d5 commit bffefb9

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/nextjs/src/app/[locale]/boards/(content)/_header-actions.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ const MobileMoreMenu = ({ showSettings }: { showSettings: boolean }) => {
269269
const tProfile = useScopedI18n("common.userAvatar.menu");
270270
const reduceMotion = useReducedMotion();
271271
const [opened, disclosure] = useDisclosure(false);
272+
const moreTriggerRef = useRef<HTMLButtonElement>(null);
272273
const pendingSectionAnchorId = useRef<string | null>(null);
273274
const desktopLayout = getDesktopLayout(board);
274275
const sections = useMemo(
@@ -284,14 +285,14 @@ const MobileMoreMenu = ({ showSettings }: { showSettings: boolean }) => {
284285
const focusPendingSection = () => {
285286
const anchorId = pendingSectionAnchorId.current;
286287
pendingSectionAnchorId.current = null;
287-
if (!anchorId) return;
288+
if (anchorId && focusMobileBoardSection({ anchorId, reduceMotion })) return;
288289

289-
focusMobileBoardSection({ anchorId, reduceMotion });
290+
moreTriggerRef.current?.focus({ preventScroll: true });
290291
};
291292

292293
return (
293294
<>
294-
<HeaderButton onClick={disclosure.open} aria-label={t("board.mobile.more")}>
295+
<HeaderButton ref={moreTriggerRef} onClick={disclosure.open} aria-label={t("board.mobile.more")}>
295296
<IconDotsVertical stroke={1.5} />
296297
</HeaderButton>
297298
<Drawer
@@ -302,6 +303,7 @@ const MobileMoreMenu = ({ showSettings }: { showSettings: boolean }) => {
302303
size="auto"
303304
padding="md"
304305
overlayProps={{ backgroundOpacity: 0.45, blur: 2 }}
306+
returnFocus={false}
305307
onExitTransitionEnd={focusPendingSection}
306308
styles={{
307309
content: {

0 commit comments

Comments
 (0)