-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
The selected attribute for <option> tags are not rendered correctly #5255
Comments
This is a naive change to use setAttribute instead, but I guess there are browser differences that might create problems, and also performance differences? |
Correct behavior is to change the property as it does, not the attribute. The attribute only indicates the initially selected option. The attribute is also correctly set for the initially selected option. This sounds like a bug with |
I'm having the same issue. On change will get the correct event information but the select element on the dom still reflects the initial value. Only on the second update (with the same selection - no change) will the select element reflect the true current selection. The only way I was able to fix this was to use the selected property on This of course gets me React warnings saying to use the value prop on Please fix this |
@StJohn3D Please try 15.0.2, it might contain the fix you need. If not, please create an example reproducing the issue. |
Made the upgrade and the behavior is the same.
The behavior is that the correct tool (React component) will show up in the dom every time the change is made and the Redux store's state is accurate. But the select will still show the last selected tool as it's value until the Redux store is updated a second time. However this small change using selected in the render function solves the issue. Albeit with warnings suggesting to use value on select components instead. Working render function using selected
|
Your first example is missing the <select value="B">
<option value="A">Apple</option>
<option value="B">Banana</option>
<option value="C">Cranberry</option>
</select> Otherwise React thinks none of them have |
Hmm, or maybe I’m wrong. Perhaps #5362 should fix it? |
It worked for me! I put value in both the select and the options and now it works without warnings. Many thanks! @gaearon |
This is still a bug probably so let’s keep it open until #5362 gets merged. |
This will cause Selenium tests to fail when using getFirstSelectedOption() to find the selected item with the Java API. This seems to affect at least 0.12 and forward. This example should set the selected attribute on the selected option-tag.
The text was updated successfully, but these errors were encountered: