Skip to content

Commit 778bf5f

Browse files
fix: focusscope navigation past visibility hidden elements (#8794)
* fix: focusscope navigation past visibility hidden elements * add comment * jsdom doesn't support this yet --------- Co-authored-by: Devon Govett <devongovett@gmail.com>
1 parent 1e05403 commit 778bf5f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/@react-aria/focus/stories/FocusScope.stories.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,34 @@ export const FocusableInputForm: FocusScopeStoryObj = {
278278
}
279279
}
280280
};
281+
282+
export let ContainsHiddenElement: FocusScopeStoryObj = {
283+
render: (args) => (
284+
<FocusScope {...args}>
285+
<input />
286+
<input style={{visibility: 'hidden'}} />
287+
<input />
288+
</FocusScope>
289+
),
290+
args: {
291+
contain: true
292+
},
293+
argTypes: {
294+
contain: {
295+
control: 'boolean'
296+
},
297+
restoreFocus: {
298+
control: 'boolean'
299+
},
300+
autoFocus: {
301+
control: 'boolean'
302+
}
303+
},
304+
parameters: {
305+
description: {
306+
data: `
307+
Should be able to tab navigate from the first input to the last input.
308+
`
309+
}
310+
}
311+
};

packages/@react-aria/utils/src/isElementVisible.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function isAttributeVisible(element: Element, childElement?: Element) {
6363
*/
6464
export function isElementVisible(element: Element, childElement?: Element): boolean {
6565
if (supportsCheckVisibility) {
66-
return element.checkVisibility() && !element.closest('[data-react-aria-prevent-focus]');
66+
return element.checkVisibility({visibilityProperty: true}) && !element.closest('[data-react-aria-prevent-focus]');
6767
}
6868

6969
return (

0 commit comments

Comments
 (0)