Repository navigation
[toggle group] Type value as string to match Toggle - #3770
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
Greptile SummaryChanged Key changes:
This change improves type safety and developer experience by preventing invalid non-string values from being passed to the toggle group while maintaining full backward compatibility since Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant ToggleGroup
participant Toggle
participant Context as ToggleGroupContext
User->>ToggleGroup: Provide value: string[]
ToggleGroup->>ToggleGroup: useControlled(value)
ToggleGroup->>Context: Store value: readonly string[]
Context-->>Toggle: Provide groupValue: readonly string[]
Toggle->>Toggle: Check value !== undefined && groupValue.indexOf(value) > -1
Toggle->>Toggle: Set pressed state (boolean)
User->>Toggle: Click toggle button
Toggle->>Toggle: Calculate nextPressed
Toggle->>ToggleGroup: Call setGroupValue(value: string, nextPressed, eventDetails)
ToggleGroup->>ToggleGroup: Update newGroupValue: string[]
ToggleGroup->>User: onValueChange(newGroupValue: string[], eventDetails)
ToggleGroup->>ToggleGroup: setValueState(newGroupValue)
ToggleGroup->>Context: Update value: readonly string[]
Context-->>Toggle: Re-render with new groupValue
|
Greptile found no issues!From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Could you please run It's worth noting that while technically it's a breaking change, any working code should still work, as it's not possible to provide anything other than a string to the Toggle. |
michaldudak
left a comment
There was a problem hiding this comment.
All right, this looks good! Thanks for your contribution, Marko!
Solves #3756
Toggle only accepts string as type for its values.