Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show text of selected non-truthy items #199

Merged
merged 1 commit into from
May 21, 2022
Merged

Conversation

hborchardt
Copy link
Contributor

Hi, thanks a lot for this project!

When adding a SelectOption Interface with an item whose value is non-truthy (for example 0), this option's text should be shown when it is selected.

An example that I would like to use is this:

    node.addInputInterface('Input', 'SelectOption', undefined, {
        items: [{ text: "on", value: 1}, { text: "off", value: 0 }]
    });

Currently, when selecting "off", the this.value is 0, which is not truthy, so "" is shown as the selected value instead of "off".

With my change, we always try to get the corresponding text from the items list. If value is set to an option that is not in
the list of options, getItemByValue will return undefined, which will be converted to an empty string, as it was before.

When adding a SelectOption Interface with an item whose value is non-truthy (for example 0),
this option's text should be shown when it is selected. If value is set to an option that is not in
the list of options, getItemByValue will return undefined, which will be converted to an empty
string, as it was before.
@newcat
Copy link
Owner

newcat commented May 21, 2022

Beautiful, thank you!

@newcat newcat merged commit f776fc3 into newcat:master May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants