fix(MultiselectInput+SelectInput): handle undefined and null values#396
fix(MultiselectInput+SelectInput): handle undefined and null values#396mgoetz-lion5 merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the SelectInput and MultiselectInput components to better handle externally-driven null/undefined model values by clearing internal selections and adding unit tests to validate these transitions.
Changes:
- Clear the currently selected option in
SelectInputwhenmodelValuebecomesnull/undefined. - Make
MultiselectInput’s model watcher treat non-array / empty values as “no selection”. - Add unit tests covering external
modelValuechanges for both components.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/src/components/inputs/SelectInput/SelectInput.vue | Clears selectedOption when the bound modelValue becomes null/undefined. |
| packages/core/src/components/inputs/SelectInput/SelectInput.spec.ts | Adds a test asserting the selection updates when modelValue changes externally (including null). |
| packages/core/src/components/inputs/MultiselectInput/MultiselectInput.vue | Updates initialization + watcher logic to reset selections when the external value isn’t a non-empty array. |
| packages/core/src/components/inputs/MultiselectInput/MultiselectInput.spec.ts | Adds a test for external modelValue transitions (including empty array and null). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
…defined handling - Fix SelectInput.spec.ts: use UI-level assertion (has-content class absence) instead of checking internal vue-multiselect modelValue when null is set - Fix MultiselectInput.vue onMounted: filter out undefined entries after mapping options to avoid runtime crashes - Widen MultiselectInput defineModel type to include null | undefined to align public typing with runtime behavior Agent-Logs-Url: https://github.com/lion5/component-library/sessions/5184580c-45c4-44a5-9908-3bb373588687 Co-authored-by: mgoetz-lion5 <262780482+mgoetz-lion5@users.noreply.github.com>
…undefined safety Agent-Logs-Url: https://github.com/lion5/component-library/sessions/5184580c-45c4-44a5-9908-3bb373588687 Co-authored-by: mgoetz-lion5 <262780482+mgoetz-lion5@users.noreply.github.com>
…aner option resolution Agent-Logs-Url: https://github.com/lion5/component-library/sessions/5184580c-45c4-44a5-9908-3bb373588687 Co-authored-by: mgoetz-lion5 <262780482+mgoetz-lion5@users.noreply.github.com>
Applied all three review changes in commit
|
Handle null and undefined values