Comments (7)
With emberx-select
, the only way that Active would be checked would be if model.status
had a value of 1
. Are you suggesting that {{x-select}}
should initialize model.status
to the first value if it is undefined?
from emberx-select.
I think that {{x-select}} should set model.status to the first value not only when it is rendered but also in cases the content of select options changes and the selected value is no longer included in the options.
Imagine a case where you have 2 selects where the second select's options are dependent on the selection of the first select;
###First selection
{{#x-select value=model.parent }}
{{#each option in array}}
{{#x-option value=option}}option.name{{/x-option}}
{{/each}}
{{/x-select}}
###2nd selection with options dependent on the 1st selection
{{#x-select value=model.child }}
{{#each option in model.parent.children}}
{{#x-option value=option}}option.name{{/x-option}}
{{/each}}
{{/x-select}}
from emberx-select.
I agree with @alexphys , and in general, since this is a select helper/native replacement, it should function in the same way, which means preselecting the initial value as well as selecting the first value in the list should the selected value be removed at a later time
from emberx-select.
The default selected attribute in x-option also has an issue.
Snippet 1:
{{#x-select class="form-control" value=SomePerson}}
{{#x-option value=0 selected}}Alice{{/x-option}}
{{#x-option value=1}}Bob{{/x-option}}
{{/x-select}}
should work similarly to the one shown below:
Snippet 2:
<select id=SomePerson>
<option value=0 selected>Alice</option>
<option value=1>Bob</option>
</select>
In snippet 1, using x-select to pass the value for SomePerson results in undefined. That shouldn't be the case.
It should pass the value as 0 which is set to selected as shown in Snippet 2.
from emberx-select.
When this will be fixed? I think this is really a major issue/bug affecting basic functionality of the addon
from emberx-select.
Hello there
I am currently working on a solution for these issues.
I understand there to be three requests:
- Fix the broken selected=true behavior for specifying a default selection
- Provide a way to default to the first option in the list on render
- Provide a way to default to the first option in the list when the selection is no longer valid because the options in the list have changed
For the time being, we can offer the following solution:
{{#x-select value=model.status }}
{{#x-option value=1}}Active{{/x-option}}
{{#x-option value=2 selected=true}}Inactive{{/x-option}}
{{/x-select}}
Will result in model.status defaulting to value=2 Inactive if model.status is not already set.
{{#x-select value=model.status }}
{{#each choices as | choice index |}}
{{#if index}}
{{#x-option value=choice.value}}{{choice.name}}{{/x-option}}
{{else}}
{{#x-option value=choice.value selected=true}}{{choice.name}}{{/x-option}}
{{/if}}
{{/each}}
{{/x-select}}
Will result in model.status defaulting to the first option in the list if model.status is not already set. This will also update correctly if the content of choices changes.
Would this solution satisfy your use cases until we can implement a more elegant solution?
from emberx-select.
This was addressed in #90 to be released in 2.1
from emberx-select.
Related Issues (20)
- Weekly Digest (9 September, 2018 - 16 September, 2018)
- Deprecation warning in Ember 3.4 HOT 1
- Behaviour of {select} integration helper, only works with `on-change`? HOT 3
- Weekly Digest (14 October, 2018 - 21 October, 2018)
- Deploys to surge not working
- ReferenceError: event is not defined - Firefox HOT 6
- Could not find module `@bigtest/interactor` HOT 5
- <xSelect> is not a component and doesn't support block parameters HOT 2
- onChange instead of on-change HOT 1
- Issue in edit case in multiple selected dropdown.
- Migrate to adopted-ember-addons
- Ensure that DEMO url continues to function after micration to adopted-ember-addons
- action arguments change order when optional argument is passed in
- When select is rendered it should not fire `onChange` action if `value` property is equal to `null` or `undefined` HOT 2
- Getting to a v4 release
- How do I upgrade to using the v4.0.0 beta
- Cannot get value HOT 1
- Usage with Octane: Error: Assertion Failed: You cannot access this.$() with `jQuery` disabled. HOT 2
- Error: Assertion Failed: You attempted to update `[]` on `<Array:ember187>`, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.
- Upgrade babel dependency to fix deprecation warning: "Deprecate the Ember Global"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emberx-select.