getSelectedValues only return previous clicked values
See original GitHub issueExpected Behavior
https://materializecss.com/select.html Say we have 3 options as described in the above link. Here are my actions and return value
# Click | Option clicked | Expected value | return from instance.getSelectedValues() |
return from e.target.value |
---|---|---|---|---|
1 | Option 1 | Option 1 |
`` | Option 1 |
2 | Option 2 | Option 2 |
Option 1 |
Option 2 |
3 | Option 3 | Option 3 |
Option 2 |
Option 3 |
4 | Option 1 | Option 1 |
Option 3 |
Option 1 |
When instance.getSelectedValues()
is called, it always return previous clicked values.
It should return the current clicked value
Current Behavior
See the return from column 4
Steps to Reproduce (for bugs)
Add the below code to the select onChange
console.log(instance.getSelectedValues());
console.log(e.target.value);
Context
Your Environment
- Version used: v1.0.0
- Browser Name and version: Chrome
- Operating System and version (desktop or mobile): Mac desktop
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Java jList1.getSelectedValue() returns an Object. I need a ...
Method getSelectedValue() from class JList returns selected object which you've added in ListModel . Either it can be a String,Integer or ...
Read more >JList (Java Platform SE 7 ) - Oracle Help Center
Returns the value for the smallest selected cell index; the selected value when only a single item is selected in the list. Object[],...
Read more >get selected values of Picklist (Multi-Select) as list of string
I'm trying to get selected values and labels of picklist (Multi-Select) for a ... I tried this and it is the same, return...
Read more >Get selected values in a multi-select drop-down with JavaScript
We can select the multiple options in the dropdown list using the multiple attribute. There are several ways in JavaScript to return the...
Read more >How to determine the items that are selected in a ListBox control
Microsoft provides programming examples for illustration only, ... The Selected property of a list box is an array of values where each value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is still an issue for me on Firefox as well. And as @weasteam mentioned, multiple seems to work but obviously defeats the purpose when multiple isn’t wanted.
It appears that _setSelectedState() is not being called at the appropriate time.
For instance, if you call instance._setSelectedState() before instance.getSelectedValues(), then the correct value is returned as expected.
See above: if you call instance._setSelectedState() before instance.getSelectedValues() then the correct value is returned, even when not using multiple.