Skip to content
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

Selectmenu: Fix selecting options following hidden ones #2144

Merged
merged 1 commit into from May 10, 2023

Conversation

mgol
Copy link
Member

@mgol mgol commented Jan 3, 2023

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
Ref a2b25ef

@mgol mgol added this to the 1.13.3 milestone Jan 3, 2023
@mgol mgol requested a review from fnagel January 3, 2023 11:36
@mgol mgol self-assigned this Jan 3, 2023
Comment on lines +398 to +399
.filter( function( item ) {
return $( item ).is( ":visible" );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change the test as the options are now back in the DOM, just hidden.

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
Copy link
Member

@fnagel fnagel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comment, otherwise looks good.

this._setText( wrapper, item.label );

if ( item.hidden ) {
li.prop( "hidden", true );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about adding hidden prop here. We don't do that anywhere else. But it seems there is no other usage of the hidden attribute, so there is nothing to compare it to directly.

What about using "aria-hidden" attribute and "ui-helper-hidden" CSS class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fnagel Sure, I can change the code. The behavior in IE 9 & 10 will be different but perhaps if the hidden attribute is there, it's expected that we should hide it even if the browser doesn't support it natively.

One thing - I see the ui-helper-hidden class definition in CSS but other than that, I don't see it anywhere in code; only the ui-helper-hidden-accessible one seems to be used. Am I missing anything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about my proposed change either :-D Just wanted to point out our options and get your opinion on it.

You are right, ui-helper-hidden is not used in JS. And ui-helper-hidden-accessible seems not correct here.

Maybe its best to use it as is it is (with the hidden property) and let the client (or its assistive technology) decide what to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I think I'd leave it at hidden. @fnagel do you have other concerns? If not, could you approve?

@mgol mgol merged commit 020828e into jquery:main May 10, 2023
@mgol mgol deleted the selectmenu-hidden-gh-2082 branch May 10, 2023 08:55
Copy link
Member

@fnagel fnagel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Hidden select and visible ui-select have different values
2 participants