Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-aria/src/interactions/Pressable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Pressable: React.ForwardRefExoticComponent<
return;
}

if (!props.isDisabled && !isFocusable(el)) {
if (!props.isDisabled && !isFocusable(el, {skipVisibilityCheck: true})) {
console.warn(
'<Pressable> child must be focusable. Please ensure the tabIndex prop is passed through.'
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-aria/src/interactions/useFocusable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const Focusable: React.ForwardRefExoticComponent<
return;
}

if (!props.isDisabled && !isFocusable(el)) {
if (!props.isDisabled && !isFocusable(el, {skipVisibilityCheck: true})) {
console.warn(
'<Focusable> child must be focusable. Please ensure the tabIndex prop is passed through.'
);
Expand Down
15 changes: 15 additions & 0 deletions packages/react-aria/test/interactions/Focusable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ describe('Focusable', function () {
);
});

it('should not warn if focusable child is inside a hidden subtree', async function () {
using spy = jest.spyOn(console, 'warn').mockImplementation(() => {});
render(
<div hidden>
<Focusable>
<span role="button">Button</span>
</Focusable>
</div>
);

expect(spy).not.toHaveBeenCalledWith(
'<Focusable> child must be focusable. Please ensure the tabIndex prop is passed through.'
);
});

it('should warn if child does not have a role', async function () {
using spy = jest.spyOn(console, 'warn').mockImplementation(() => {});
render(
Expand Down
15 changes: 15 additions & 0 deletions packages/react-aria/test/interactions/Pressable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,21 @@ describe('Pressable', function () {
);
});

it('should not warn if focusable child is inside a hidden subtree', async function () {
using spy = jest.spyOn(console, 'warn').mockImplementation(() => {});
render(
<div hidden>
<Pressable>
<span role="button">Button</span>
</Pressable>
</div>
);

expect(spy).not.toHaveBeenCalledWith(
'<Pressable> child must be focusable. Please ensure the tabIndex prop is passed through.'
);
});

it('supports isDisabled', async function () {
using spy = jest.spyOn(console, 'warn').mockImplementation(() => {});
let {getByRole} = render(
Expand Down