aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-05-10 10:55:01 +0200
committerGitHub <noreply@github.com>2023-05-10 10:55:01 +0200
commit020828e7ffd5e7830d979b4c5cf8412f04223973 (patch)
tree323d777eaabdabbdce36008926817275df7d9a8b /ui
parentbeeb410ccbe1c4108ee93bdbdc05e003f115baf6 (diff)
downloadjquery-ui-020828e7ffd5e7830d979b4c5cf8412f04223973.tar.gz
jquery-ui-020828e7ffd5e7830d979b4c5cf8412f04223973.zip
Selectmenu: Fix selecting options following hidden ones
Change a2b25ef6caae3e1a272214839b815a6387618124 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 a2b25ef6caae3e1a272214839b815a6387618124
Diffstat (limited to 'ui')
-rw-r--r--ui/widgets/selectmenu.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js
index 79e1eacc9..c80e39f60 100644
--- a/ui/widgets/selectmenu.js
+++ b/ui/widgets/selectmenu.js
@@ -354,7 +354,12 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
if ( item.disabled ) {
this._addClass( li, null, "ui-state-disabled" );
}
- this._setText( wrapper, item.label );
+
+ if ( item.hidden ) {
+ li.prop( "hidden", true );
+ } else {
+ this._setText( wrapper, item.label );
+ }
return li.append( wrapper ).appendTo( ul );
},
@@ -658,10 +663,6 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
var that = this,
data = [];
options.each( function( index, item ) {
- if ( item.hidden ) {
- return;
- }
-
data.push( that._parseOption( $( item ), index ) );
} );
this.items = data;
@@ -675,6 +676,7 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
index: index,
value: option.val(),
label: option.text(),
+ hidden: optgroup.prop( "hidden" ) || option.prop( "hidden" ),
optgroup: optgroup.attr( "label" ) || "",
disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
};