-
Notifications
You must be signed in to change notification settings - Fork 307
fix: ButtonToggleGroup initial value #1661
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
base: main
Are you sure you want to change the base?
fix: ButtonToggleGroup initial value #1661
Conversation
@cc-nogueira is attempting to deploy a commit to the Themesberg Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe initialization logic for the Changes
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/lib/forms/button-toggle/ButtonToggleGroup.svelte (1)
5-5
: Address the TypeScriptany
type usage.The
any
type in theonSelect
callback reduces type safety. Consider using a more specific type based on the expected value format.-onSelect = (val: any) => {} +onSelect = (val: SelectedValue) => {}Since
SelectedValue
is already defined on line 8, this would provide better type safety while maintaining the same functionality.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lib/forms/button-toggle/ButtonToggleGroup.svelte
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.952Z
Learning: In the Flowbite Svelte library, when implementing components with validation states, the 'inputInvalid' property should be explicitly defined and passed to the Wrapper component. When inputInvalid=true, the color should be set to "red" to ensure the ring/border styling is applied correctly.
Learnt from: Chizaruu
PR: themesberg/flowbite-svelte#1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In `Timepicker.svelte`, the `Dropdown` opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
src/lib/forms/button-toggle/ButtonToggleGroup.svelte (1)
Learnt from: mrh1997
PR: themesberg/flowbite-svelte#1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In `src/lib/utils/Popper.svelte`, inconsistencies in event handling (e.g., using both `mouseenter`/`mouseleave` and `pointerenter`/`pointerleave`) may be intentional to minimize modifications and reduce the risk of new problems.
🪛 ESLint
src/lib/forms/button-toggle/ButtonToggleGroup.svelte
[error] 5-5: Unexpected any. Specify a different type.
(@typescript-eslint/no-explicit-any)
🔇 Additional comments (2)
src/lib/forms/button-toggle/ButtonToggleGroup.svelte (2)
10-21
: Excellent fix for initial value handling!This normalization logic properly addresses the reported issue where initial values were being ignored. The implementation correctly:
- Converts single values to arrays when
multiSelect
is true- Converts arrays to single values when
multiSelect
is false- Handles null values appropriately for both modes
- Maintains type consistency throughout the component
This ensures that whatever initial value format is passed in gets normalized to the expected internal representation.
22-22
: Proper initialization from normalized value.Good change! Now
selectedValues
is correctly initialized from the normalizedvalue
, ensuring the initial state respects the user-provided value instead of always defaulting to empty/null values.
Set the initial value passed to a
ButtonToggleGroup
value prop.The value passed in was being ignored is the component.
Status
✅ Checks
Summary by CodeRabbit