Skip to content

Commit 8fdf6be

Browse files
authored
fix(BottomSheet): a sheet removed while open returns focus where a close would (#10061)
* fix(BottomSheet): a sheet removed while open returns focus where a close would * fix(BottomSheet): the removal repair runs with the registration, and a whole stack removed at once returns focus to its first opener * fix(BottomSheet): when the sheet beneath left too, its repair returns focus for the stack * docs(BottomSheet): FR19 covers standalone sheets; a removed switcher flow is a recorded gap * fix(BottomSheet): focus that rested on the page body before a removal stays there * refactor(BottomSheet): the shared removal repair decides whether focus rested on the page * docs(BottomSheet): the removal rule is FR20, so FR19 stays with the drag checks * Merge branch 'main' into fix/bottomsheet-unmount-returns-focus
1 parent f384e62 commit 8fdf6be

6 files changed

Lines changed: 528 additions & 19 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[fix] BottomSheet: a standalone sheet (not a `BottomSheetSwitcher` step) removed while it is open (rendered only while open, or removed with the rest of a view) returns focus where a close would send it, while that place is still on the page: to `finalFocusRef`, else the control that opened it, or into the sheet beneath. A whole stack of standalone sheets removed at once returns focus to the first sheet's `finalFocusRef` or opener. When none of these is left on the page, for example when the opener is removed with the sheet, focus stays where the browser leaves it. Focus the person had already moved out of a sheet, to the page body, stays where it is. A sheet that opens in the same update keeps focus, and removing a covered sheet under a top sheet that stays moves no focus.
6+
7+
@cixzhang

‎apps/storybook/stories/BottomSheet.stories.tsx‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,3 +1044,36 @@ export const ExitFocusControlDisabled: Story = {
10441044
tags: ['!autodocs'],
10451045
render: () => <ExitFocusChangeFixture change="disable" />,
10461046
};
1047+
1048+
/**
1049+
* A sheet rendered only while it is open. "Done" removes the sheet while it is
1050+
* still open; focus returns to "Edit filters" (FR20).
1051+
*/
1052+
export const RenderedWhileOpen: Story = {
1053+
render: () => {
1054+
const [isOpen, setIsOpen] = useState(false);
1055+
const [hasScrim, setHasScrim] = useState(true);
1056+
return (
1057+
<VStack gap={2}>
1058+
<CheckboxInput
1059+
label="Modal (scrim)"
1060+
value={hasScrim}
1061+
onChange={setHasScrim}
1062+
/>
1063+
<Button label="Edit filters" onClick={() => setIsOpen(true)} />
1064+
{isOpen && (
1065+
<BottomSheet
1066+
isOpen
1067+
onOpenChange={setIsOpen}
1068+
hasScrim={hasScrim}
1069+
label="Filters">
1070+
<VStack gap={2}>
1071+
<Text>Removing this sheet while it is open returns focus.</Text>
1072+
<Button label="Done" onClick={() => setIsOpen(false)} />
1073+
</VStack>
1074+
</BottomSheet>
1075+
)}
1076+
</VStack>
1077+
);
1078+
},
1079+
};

0 commit comments

Comments
 (0)