CascadeSelect breaks when modelValue doesn't exist in the options #7246
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Describe the bug
CascadeSelect breaks when there is no corresponding option which matches
modelValue
. Initial render is fine, but errors out when opening the list container:Triage
In
show()
method, this line:sets
activeOptionPath
toundefined
, which then ends up breaking later inisSelected
:I'd be happy to contribute a PR with a little guidance. Should
this.activeOptionPath = undefined
be an acceptable state? That would mean we'd need a conditional check everywhere it's referenced (isSelected, onOptionChange, onOptionClick, etc). Or, shouldfindOptionPathByValue
return[]
when no option is found? The latter seems simpler, but it's hard to know all the implications without more sufficient test coverage.Workaround
Push an option that always matches
modelValue
. Hide or disable it usingpt
passthrough if necessary. Seems to work as expected even if that optionValue is a duplicate.Pull Request Link
No response
Reason for not contributing a PR
Other Reason
Lack of test coverage in the codebase
Reproducer
https://stackblitz.com/edit/evp36zku?file=src%2FApp.vue
Environment
Latest version of PV and Vue. Styled mode w/ Tailwind v3.
Vue version
3.5.13 (also reproducible on Stackblitz v3.2.45)
PrimeVue version
4.2.5
Node version
No response
Browser(s)
No response
Steps to reproduce the behavior
modelValue
to something that doesn't exist inoptions
Expected behavior
CascadeSelect dropdown opens with nothing selected.
The text was updated successfully, but these errors were encountered: