feat(pds-multiselect): add searchPlaceholder, closePanelOnSelect, dis…#674
Conversation
…miss event, and clear method
✅ Deploy Preview for pine-design-system ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@coderabbitai review this pr |
|
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis pull request extends the pds-multiselect component with four new public API features. A 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
libs/core/src/components/pds-multiselect/pds-multiselect.tsx (1)
948-978:⚠️ Potential issue | 🟠 MajorNormalize value entries to strings before toggling.
WithoptionIdstringification, numeric values (e.g., from JSONvalue='[1,2]'or programmatic usage) will no longer match and can create duplicates/incorrect counts on toggle. Normalize the current value array beforeincludes/filter/add.🛠️ Proposed fix
- const optionId = String(option.id); - const isSelected = this.value.includes(optionId); + const optionId = String(option.id); + const normalizedValue = this.ensureValueArray().map(v => String(v)); + const isSelected = normalizedValue.includes(optionId); if (isSelected) { - this.value = this.value.filter(v => v !== optionId); + this.value = normalizedValue.filter(v => v !== optionId); } else { - if (this.maxSelections && this.value.length >= this.maxSelections) { + if (this.maxSelections && normalizedValue.length >= this.maxSelections) { return; } - this.value = [...this.value, optionId]; + this.value = [...normalizedValue, optionId]; }
There was a problem hiding this comment.
Code Review
Overall this is a well-executed PR. The features are well-scoped, documented, and tested. Solid work on the Sage parity additions. A few suggestions inline — the main concern is around potential focus-out timing with closePanelOnSelect. The rest are minor nits.
Description
Adds Sage
SelectDropdownparity features topds-multiselectto unblock migration from Sage to Pine in kajabi-products.Fixes DSS-163
New features:
searchPlaceholderprop — customize the search input placeholder text (defaults to "Find...")closePanelOnSelectprop — close the dropdown panel after each selection (defaults tofalse)pdsMultiselectDismissevent — fires when the panel is dismissed via Escape key or click-outside, enabling parent components to react (maps to Sage'sonEscapeHook)clear()method — programmatic reset of all selections, search query, and form value (maps to Sage'sresetTokenpattern)Note: Single-select use cases (Sage's
allowMultiselect={false}) should usepds-comboboxrather thanpds-multiselect.Type of change
How Has This Been Tested?
16 new unit tests covering:
searchPlaceholderprop (custom text, default fallback)pdsMultiselectDismissevent (Escape key fires event, no-op when closed)closePanelOnSelectprop (default keeps panel open,truecloses panel)clear()method (clears values, resets trigger text, emits change event)Storybook stories added for
CustomSearchPlaceholderandClosePanelOnSelect. MDX docs updated with examples for all four features including live interactive demos.Checklist: