Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Switch] fix : Hidden input for Switch does not render "over the button" #3250

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Brokyeom
Copy link

Closes #3235

Description

The BubbleInput within the Switch component had an absolute positioning applied, but there was no parent node with relative positioning, causing the component to overflow its intended area.

  • Added a div wrapper around <Primitive.button /> and <BubbleInput /> and applied the necessary styles.
  • Removed the transform: translate(-100%) property previously applied as an inline style on BubbleInput.

AS-IS

image

TO-BE

image

Test Result

image

Storybook

image

- Fixed the issue where BubbleInput was positioned incorrectly
- Adjusted positioning by wrapping with a div to align the Input within the Button area
@Brokyeom Brokyeom changed the title fix(Switch): BubbleInput position issue in Switch component fix(Switch): Hidden input for Switch does not render "over the button" Nov 24, 2024
Wrap with div to prevent input from escaping component bounds
link : https://github.com/radix-ui/primitives/issues/3235
*/}
<div style={{ position: 'relative', display: 'inline-flex' }}>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add div element.

// We transform because the input is absolutely positioned but we have
// rendered it **after** the button. This pulls it back to sit on top
// of the button.
style={{ transform: 'translateX(-100%)' }}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove transform inline style.

@Brokyeom Brokyeom changed the title fix(Switch): Hidden input for Switch does not render "over the button" [Switch] fix : Hidden input for Switch does not render "over the button" Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hidden input for Switch does not render "over the button"
1 participant