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

Select prompt if value is not a valid option #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

czosel
Copy link

@czosel czosel commented Jan 30, 2018

Moved over from DavyJonesLocker/ember-one-way-controls#163, original message was

Currently, a one-way-selects's prompt is only selected when the current value is empty. When value is not empty but also not a valid option, the browser initially renders the first passed option instead of the prompt, because none of the options have a selected attribute and the prompt itself has the disabled attribute.

All that wouldn't be much of an issue if one doesn't pass invalid options, right? Well, it turns out that if value is an ember data relation, nothingSelected evaluates to false because it sees a promise. When the promise resolves to null, the first option stays selected because nothingSelected is still false (see #127 and probably also #159).

Instead of using empty to determine nothingSelected, I'd propose checking if the passed value is actually a valid option. That doesn't only solve the first issue when an actually invalid option is passed, but also the second issue related to ember-data relations.

@czosel
Copy link
Author

czosel commented Jan 5, 2022

This PR is very old, but I think it's still correct and even still conflict-free. Is there anything I can do to help landing it?

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