Provide a general summary of the issue here
The VisuallyHidden component from react-aria, used as described by the documentation, breaks page styling at certain viewport dimensions. Namely, if the element that it's being used with is offscreen and needs to be scrolled to in order to be interacted with, doing so will break the height and flex flow of the parent container in some strange way.
When using components like checkbox, radio or switch, you are not aware about this issue.
🤔 Expected Behavior?
Using components like checkbox, radio or switch, which uses the VisuallyHidden component should have no effect on the rest of the page.
😯 Current Behavior
Interacting with a component that uses VisuallyHidden breaks the surrounding page layout when a child component of it get's focused but is offsceen
💁 Possible Solution
Components that make use of <VisuallyHidden /> should have a position: relative styling per default or <VisuallyHidden /> needs a wrapper that does that.
🔦 Context
Using the component as described by the documentation breaks my application's styling, something which took a good chunk of time to pinpoint. The VisuallyHidden component should only hide its children nodes and have no effect on the rest of the DOM.
This issue is known in #5094 but the solution is not clearly visible for users of the library.
The actual "fix" is just hidden soemwhere in the example CSS.
🖥️ Steps to Reproduce
- Open this example.
- Resize your browser window so that the checkboxes at the bottom of each column overflow off the bottom of the screen.
- Scroll down to the bottom checkboxes. Click "Working Option 15" and observe that it behaves exactly as you'd expect.
- Now click "Broken Option 15" and observe that it breaks the page layout by shifting everything upwards
- Open the source code here. Observe that the
Checkbox component - the one that does not break the styling - applies a display: none rule to the input element in order to hide it, rather than using the VisuallyHidden component from react-aria. Observe that the CheckboxWithVisuallyHidden component does use VisuallyHidden, and that interacting with that version of the checkbox breaks the page.
Version
1.13.0
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
Windows 11 Pro 25H2 26200.8246
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Provide a general summary of the issue here
The
VisuallyHiddencomponent fromreact-aria, used as described by the documentation, breaks page styling at certain viewport dimensions. Namely, if the element that it's being used with is offscreen and needs to be scrolled to in order to be interacted with, doing so will break the height and flex flow of the parent container in some strange way.When using components like
checkbox,radioorswitch, you are not aware about this issue.🤔 Expected Behavior?
Using components like
checkbox,radioorswitch, which uses theVisuallyHiddencomponent should have no effect on the rest of the page.😯 Current Behavior
Interacting with a component that uses
VisuallyHiddenbreaks the surrounding page layout when a child component of it get's focused but is offsceen💁 Possible Solution
Components that make use of
<VisuallyHidden />should have aposition: relativestyling per default or<VisuallyHidden />needs a wrapper that does that.🔦 Context
Using the component as described by the documentation breaks my application's styling, something which took a good chunk of time to pinpoint. The
VisuallyHiddencomponent should only hide its children nodes and have no effect on the rest of the DOM.This issue is known in #5094 but the solution is not clearly visible for users of the library.
The actual "fix" is just hidden soemwhere in the example CSS.
🖥️ Steps to Reproduce
Checkboxcomponent - the one that does not break the styling - applies adisplay: nonerule to theinputelement in order to hide it, rather than using theVisuallyHiddencomponent fromreact-aria. Observe that theCheckboxWithVisuallyHiddencomponent does useVisuallyHidden, and that interacting with that version of the checkbox breaks the page.Version
1.13.0
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
Windows 11 Pro 25H2 26200.8246
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response