You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the VisuallyHidden component inside containers with overflow: hidden or overflow-y: scroll, the component extends beyond its parent container boundaries, causing unwanted scrollbars to appear or content to overflow. This creates unexpected scrolling behavior in parent components.
Expected behavior
The VisuallyHidden component should remain within its parent container boundaries and not trigger any scrolling behavior in parent components, while still maintaining its accessibility functionality.
The issue can likely be fixed by adding explicit positioning (top: 0 and left: 0) to the VisuallyHidden component's inline styles. This would properly constrain the element within its parent container.
I initially discovered this issue when using the Form component and noticed unexpected scrollbars. After investigating further through Select component, I traced the problem back to the VisuallyHidden component.
This suggests that the issue may affect all components that use VisuallyHidden internally, including Form, Select, and others.
To debug the issue, I modified the VisuallyHidden component by removing the clip rect, adding background color, and increasing its width and height. This revealed that the component was positioning itself at the bottom of the container without respecting the height limitations of the overflow container, which is what triggered the unwanted scrollbars. Adding explicit top: 0 and left: 0 positioning properties constrains the element properly within its parent boundaries.
Your environment
Software
Name(s)
Version
Radix Package(s)
@radix-ui/react-visually-hidden
1.1.2
React
n/a
18.2.0
Browser
Chrome
Latest
Assistive tech
N/A
N/A
Node
n/a
N/A
npm/yarn
npm
N/A
Operating System
CodeSandbox Environment
N/A
TypeScript
n/a
4.4.4
React Scripts
n/a
5.0.1
The text was updated successfully, but these errors were encountered:
I encountered the same situation in the shadcn UI based on the radix UI, where the select component in a div box with the overflow x-auto attribute resulted in a white border that caused the entire page to display a scrollbar. How can I solve this problem? Thank you very much
I encountered the same situation in the shadcn UI based on the radix UI, where the select component in a div box with the overflow x-auto attribute resulted in a white border that caused the entire page to display a scrollbar. How can I solve this problem? Thank you very much
Although it doesn't seem like a good solution, but as a temporary workaround, you can easily solve this by setting position relative on one of the parent elements that contains the Select component.
Bug report
Current Behavior
When using the
VisuallyHidden
component inside containers withoverflow: hidden
oroverflow-y: scroll
, the component extends beyond its parent container boundaries, causing unwanted scrollbars to appear or content to overflow. This creates unexpected scrolling behavior in parent components.Expected behavior
The
VisuallyHidden
component should remain within its parent container boundaries and not trigger any scrolling behavior in parent components, while still maintaining its accessibility functionality.Reproducible example
CodeSandbox Example
Suggested solution
The issue can likely be fixed by adding explicit positioning (
top: 0
andleft: 0
) to the VisuallyHidden component's inline styles. This would properly constrain the element within its parent container.Additional context
I initially discovered this issue when using the Form component and noticed unexpected scrollbars. After investigating further through Select component, I traced the problem back to the VisuallyHidden component.
This suggests that the issue may affect all components that use VisuallyHidden internally, including Form, Select, and others.
To debug the issue, I modified the VisuallyHidden component by removing the clip rect, adding background color, and increasing its width and height. This revealed that the component was positioning itself at the bottom of the container without respecting the height limitations of the overflow container, which is what triggered the unwanted scrollbars. Adding explicit
top: 0
andleft: 0
positioning properties constrains the element properly within its parent boundaries.Your environment
The text was updated successfully, but these errors were encountered: