fix(switch): correct data-active consistency on disabled state#2734
Merged
segunadebayo merged 3 commits intochakra-ui:mainfrom Sep 24, 2025
julienbenac:fix/switch-active-attr
Merged
fix(switch): correct data-active consistency on disabled state#2734segunadebayo merged 3 commits intochakra-ui:mainfrom julienbenac:fix/switch-active-attr
data-active consistency on disabled state#2734segunadebayo merged 3 commits intochakra-ui:mainfrom
julienbenac:fix/switch-active-attr
Conversation
🦋 Changeset detectedLatest commit: 2b9dedb The changes in this PR will be included in the next version bump. This PR includes changesets to release 79 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2732
📝 Description
This PR fixes an issue where the
data-activeattribute could be added to aSwitchcomponent even when it was disabled at runtime. Now,data-activeis never set if the switch is disabled, whether from the start or after being updated.⛳️ Current behavior (updates)
If a
Switchis enabled and then disabled dynamically, clicking it still addsdata-active. This does not happen if it starts disabled.🚀 New behavior
With this change,
data-activeis never added to a disabledSwitch, regardless of when it becomes disabled.💣 Is this a breaking change (Yes/No):
Yes, if the
data-activeattribute is used in conjunction with thedisabledprop. Styles may be affected if both selectors are used together, as thedata-activeattribute will no longer be present on disabled switches.Before
After
📝 Additional Information
This behavior is also present in similar state machines such as
RadioGroupandCheckbox. ThereadOnlyproperty could potentially cause similar issues asdisabled. However, these cases have not been addressed in this pull request and may require further investigation.