-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix #8 - Dropdown not showing initial value when list is computed #7
Fix #8 - Dropdown not showing initial value when list is computed #7
Conversation
Hi @ssshake . I needed to add 1e8cad4, because the solution above causes a regression in data binding - the host path is no longer able to set or receive changes. |
… list is computed Cause: When the options list is a computed, the value will get assigned before it. This loses the value, because the native select's `.value` setter will change it to '' when it can't find the option (which is always the case here, because they haven't been assigned yet). The original <select><template is=dom-repeat items=getAirportsForCity(city)></select> doesn't have the issue because templates are evaluated from leaves to roots.
…alue contains something and using like: `<select value={{val::change}}>)` Occurs only when the options list is a computed, the value will get assigned before it, which loses the value, because the native select's .value setter will change it to '' when it can't find the option (which is always the case here, because they haven't been assigned yet). Fixed by refactoring so that we never remove the static options in the optionsList observer (which seems right, because optionList only affects the dynamic options) and only update the visible selected option using the `.selected` property (which also takes care of #4).
…changed so that currently selected value becomes unavailable. The problem is hinted in #4 (comment) and this commit introduces this sensible default. It's a sensible default as otherwise user will be able to submit a value that according to UI logic is clearly not a valid one. The native select's `.value` accessor also resets to `''` when the value is not found, so is the natural choice. This can be disabled by `keep-value-with-no-matching-option=true`
…onger able to set or receive changes
…select not receiving changes from the host path - needed to override the value property which also entailed a need to add artificial firing of the 'change' event :(
I had this kind of issue on Safari where the drop down list was showing no selected value. |
Thanks @ssshake |
Thanks @ssshake. How about creating a release, so users have something to hook onto that isn't a hash? |
That would be a good idea to add a new version tag yes, for bower for example. |
Hi @ssshake. Just found this issue in our project (see title).
See reproduction.
Cause: When the options list is a computed, the value binding will get assigned before the options computation adds any options. This loses that value, because the native select's
.value
setter will change it to''
when it can't find the option.The original doesn't have the issue because templates are evaluated from leaves to roots.
See commit message of 'the fix commit' for details.
I've also added a solution to the remark I saw in #4, one that states that the PR 'Replaces a larger bug with a smaller one':
See commit message of the second small commit for details.