feat: Add data attributes for selected and active items in MulitSelect#1877
feat: Add data attributes for selected and active items in MulitSelect#1877shinokada merged 3 commits intothemesberg:mainfrom
Conversation
|
@PhilipHansen is attempting to deploy a commit to the Themesberg Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughAdds per-item bindings Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/lib/forms/select/MultiSelect.svelte (1)
248-260: Optional: make data attributes presence-based and avoid duplicate expressionsThis works as-is, but two small refinements could make it nicer for consumers:
data-selected/data-activewill always be present with"true"or"false". For styling and tests it’s often more ergonomic if the attribute only exists when the state is true (so you can use[data-selected]/[data-active]).- The
selectItems.includes(item)andactiveItem === itemchecks are now repeated three times in this block.You could refactor like:
{#each items as item (item.value)} {#key item.value} {#let isSelected = selectItems.includes(item)} {#let isActive = activeItem === item} <div onclick={(e) => selectOption(item, e)} role="presentation" class={dropdownItem({ selected: isSelected, active: isActive, disabled: item.disabled, class: clsx(classes?.item) })} data-selected={isSelected ? "true" : undefined} data-active={isActive ? "true" : undefined} > {item.name} </div> {/key} {/each}(or similar using local
constvariables inside the loop), keeping behavior but simplifying usage and avoiding repeated checks.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lib/forms/select/MultiSelect.svelte(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{svelte,ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{svelte,ts,tsx,js,jsx}: Use the Flowbite-Svelte MCP server to discover components by name or category before implementing UI components
Always use findComponent tool FIRST to locate the correct Flowbite-Svelte component before fetching documentation
After calling findComponent, use getComponentDoc tool to fetch complete documentation including usage examples, props, and best practices for Flowbite-Svelte components
Files:
src/lib/forms/select/MultiSelect.svelte
|
Please see Coderabbitai's Nitpick comment. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Can you run |
|
@shinokada Apologies -- did that the first time, but not after applying CodeRabbit's suggestion |
📑 Description
Adds
data-selectedanddata-activeattributes to items in the dropdown within theMultiSelectcomponent🔍 PR Type
🚦 PR Status
✅ Checklist
pnpm lint && pnpm check && pnpm test:e2eand all tests passmainbranch (not the published npm version)ℹ️ Additional Information
While using Flowbite within our Svelte project, we have been trying to find a way to customize the styling of the items within the dropdown of the MultiSelect component. We can add classes to the items, but couldn't find a good way to style them when selected or active. We found that by adding these
data-attributes to the items, we were able to solve this problem, in the least intrusive manner possible.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.