Ensure the state is a string or an array of strings when initializing the select

This commit is contained in:
Sandro Gehri
2025-09-01 11:05:07 +02:00
parent 749a7de6ff
commit d41a546de2
@@ -51,6 +51,12 @@ export class Select {
statePath = null,
onStateChange = () => {},
}) {
if (Array.isArray(state)) {
state = state.map((item) => item.toString())
} else if (state !== null) {
state = state.toString()
}
this.element = element
this.options = options
this.originalOptions = JSON.parse(JSON.stringify(options)) // Keep a copy of original options
@@ -600,7 +606,7 @@ export class Select {
}
// If not found, add to missing values
missingValues.push(value.toString())
missingValues.push(value)
}
}