A subtle but important difference to the vscode-ui-toolkit is the lack of support for empty options in a select box.
Becaus of this line in _addOptionsFromSlottedElements(), we will always default to the slot element name instead of the actual provided value if that value is falsy like an empty string is.
|
const value = (el.value ?? '') ? el.value : innerText.trim(); |
I was using an empty value of '' to preselect a placeholder element, which isn't possible with this library. Would you consider changing the behaviour here? I tested the change locally and it seemed quite small, basically only changing that line of code and the default option value here:
|
@property({type: String}) value = ''; |
This way we could fall back to the slotted text when there is no value but use the provided value if it exists (even if it's empty).
What do you think? Maybe there's a good reason for this behaviour that I'm missing, open to discuss :)
A subtle but important difference to the vscode-ui-toolkit is the lack of support for empty options in a select box.
Becaus of this line in
_addOptionsFromSlottedElements(), we will always default to the slot element name instead of the actual provided value if that value is falsy like an empty string is.elements/src/includes/vscode-select/vscode-select-base.ts
Line 222 in b5300ba
I was using an empty value of
''to preselect a placeholder element, which isn't possible with this library. Would you consider changing the behaviour here? I tested the change locally and it seemed quite small, basically only changing that line of code and the default option value here:elements/src/vscode-option/vscode-option.ts
Line 10 in b5300ba
This way we could fall back to the slotted text when there is no value but use the provided value if it exists (even if it's empty).
What do you think? Maybe there's a good reason for this behaviour that I'm missing, open to discuss :)