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

When a Switch is selected it's checkbox is not checked #7582

Open
armandabric opened this issue Jan 8, 2025 · 2 comments
Open

When a Switch is selected it's checkbox is not checked #7582

armandabric opened this issue Jan 8, 2025 · 2 comments

Comments

@armandabric
Copy link
Contributor

armandabric commented Jan 8, 2025

Provide a general summary of the issue here

The hidden checkbox that power the Switch seems to not be in with the Switch isSelected state.

🤔 Expected Behavior?

When the Switch is selected, the hidden checkbox should have the attribute checked="".
When the Switch is not selected, the hidden checkbox should not have the attribute checked="".

😯 Current Behavior

If neither defaultSelected or isSelected are used the checked="" attribute is never added to the hidden checkbox.

If defaultSelected=true the hidden checkbox have the checked="" attribute at first render. But when the Switch is toggle, the checked="" attribute is still present.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

https://codesandbox.io/p/sandbox/pedantic-snowflake-6sm9h5?workspaceId=ws_3TnnD19dp7Tmr52NkWtSat

You can also try any switch of the documentation page

Version

RAC 1.5.0
React 18 & 19

What browsers are you seeing the problem on?

Other

If other, please specify.

All browsers

What operating system are you using?

Ubuntu

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@LFDanLu
Copy link
Member

LFDanLu commented Jan 8, 2025

Seems like the value is updating under the hood but just not updating in the DOM:
image
Maybe related to facebook/react#3005. Is this behavior causing any specific issues?

@armandabric
Copy link
Contributor Author

@LFDanLu It's preventing the parent form to work as intended. I have to manually add hidden input in my custom Toggle to make it works.

@armandabric armandabric changed the title When a Switch is selected it's checkbox is no checked When a Switch is selected it's checkbox is not checked Jan 9, 2025
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

No branches or pull requests

2 participants