Skip to content

vscode-option with empty '' value is not supported #237

@MaxKless

Description

@MaxKless

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions