-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Hidden select and visible ui-select have different values #2082
Comments
Thanks for the report. This looks like a 1.13 regression as it works fine with 1.12.1: |
It looks like I messed the 1.12.1 version of the test case above. So, let me share new ones with the latest version of jQuery jQuery UI for each line:
|
The first bad commit is a2b25ef. There's even a comment from 4 years ago suggesting a similar issue: a2b25ef#commitcomment-26579991 |
Change a2b25ef Made options with the `hidden` attribute skipped when rendering. However, that makes indexes misaligned with native options as hidden ones maintain their index values. Instead, don't skip hidden options but add the `hidden` attribute to the respective jQuery UI elements as well. Fixes jquerygh-2082 Ref a2b25ef
Change a2b25ef made options with the `hidden` attribute skipped when rendering. However, that makes indexes misaligned with native options as hidden ones maintain their index values. Instead, don't skip hidden options but add the `hidden` attribute to the respective jQuery UI elements as well. Fixes jquerygh-2082 Ref a2b25ef
PR with a fix: #2144 |
Change a2b25ef made options with the `hidden` attribute skipped when rendering. However, that makes indexes misaligned with native options as hidden ones maintain their index values. Instead, don't skip hidden options but add the `hidden` attribute to the respective jQuery UI elements as well. Fixes jquerygh-2082 Ref a2b25ef
Change a2b25ef made options with the `hidden` attribute skipped when rendering. However, that makes indexes misaligned with native options as hidden ones maintain their index values. Instead, don't skip hidden options but add the `hidden` attribute to the respective jQuery UI elements as well. Fixes gh-2082 Closes gh-2144 Ref a2b25ef
When I hide options in my select by setting the hidden attribute and also preselect an option, then I get an error when opening the selectmenu.
Here is the code the jquery executes until the error occures:
... this.button.one( "focusin"); -> that._refreshMenu(); -> this._getSelectedItem().data( "ui-selectmenu-item" ); -> this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
This happens because the options' DOM-element attribute selectedIndex does not match the index from the rendered ui-select-menu.
When I start selecting other entries now, the native select has a different value than what is displayed in the ui-selectmenu-button.
I also created a fiddle, in which the selectmenu won't open at all.
https://jsfiddle.net/isaraystanz/750p69qu/19/
On my local system the selectmenu will show and I can select entries, but the select's value gets messed up so I can't use it safely.
The text was updated successfully, but these errors were encountered: