Skip to content

The VisuallyHidden component from the React Aria library breaks styling under certain conditions #5094

Open
@zachkaigler

Description

@zachkaigler

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.

🤔 Expected Behavior?

Using 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 under the conditions mentioned above and shown in the below example.

💁 Possible Solution

No response

🔦 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.

🖥️ Steps to Reproduce

  1. Open this example.
  2. Resize your browser window so that the checkboxes at the bottom of each column overflow off the bottom of the screen.
  3. Scroll down to the bottom checkboxes. Click "Working Option 15" and observe that it behaves exactly as you'd expect.
  4. Now click "Broken Option 15" and observe that it breaks the page layout by shifting everything upwards
  5. 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

"react-aria": "^3.28.0",

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

MacOS Ventura 13.3.1

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      🩺 To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions