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

one-way-select: select prompt if value is not a valid option #163

Closed
wants to merge 1 commit into from

Conversation

czosel
Copy link

@czosel czosel commented Jul 6, 2017

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 30, 2018

Closing in favor of DockYard/ember-one-way-select#1

@czosel czosel closed this Jan 30, 2018
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.

1 participant