Skip to content

Focusable: Fix handling of visibility: collapse #1843

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

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Focusable: Fix handling of visibility: collapse
"collapse" is similar to "hidden", with a slight difference in the case
of tr/tbody/td/colgroup elements.
See https://www.w3.org/TR/CSS22/visufx.html#visibility
See https://www.w3.org/TR/CSS22/tables.html#dynamic-effects
See https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#Table_example

"visibility: collapse" elements are always not focusable, though.

Commit d302596 introduced a regression by testing with `!== "hidden"`
instead of `=== "visible"`.
  • Loading branch information
PaulCapron committed Oct 31, 2017
commit b3a9875af61a558f5ee566feb491511b254ad020
8 changes: 8 additions & 0 deletions tests/unit/core/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,17 @@

<span tabindex="1" id="displayNone-span" style="display: none;">.</span>
<span tabindex="1" id="visibilityHidden-span" style="visibility: hidden;">.</span>
<span tabindex="1" id="visibilityCollapse-span" style="visibility: collapse;">.</span>

<input id="displayNone-input" style="display: none;">
<input id="visibilityHidden-input" style="visibility: hidden;">
<input id="visibilityCollapse-input" style="visibility: collapse;">

<table>
<tr>
<td tabindex="1" id="visibilityCollapse-td" style="visibility: collapse;">.</td>
</tr>
</table>
</div>

<div>
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/core/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ QUnit.test( "focusable - disabled elements", function( assert ) {
} );

QUnit.test( "focusable - hidden styles", function( assert ) {
assert.expect( 12 );
assert.expect( 15 );

assert.isNotFocusable( "#displayNoneAncestor-input", "input, display: none parent" );
assert.isNotFocusable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" );
Expand All @@ -148,9 +148,13 @@ QUnit.test( "focusable - hidden styles", function( assert ) {

assert.isNotFocusable( "#displayNone-input", "input, display: none" );
assert.isNotFocusable( "#visibilityHidden-input", "input, visibility: hidden" );
assert.isNotFocusable( "#visibilityCollapse-input", "input, visibility: collapse" );

assert.isNotFocusable( "#displayNone-span", "span with tabindex, display: none" );
assert.isNotFocusable( "#visibilityHidden-span", "span with tabindex, visibility: hidden" );
assert.isNotFocusable( "#visibilityCollapse-span", "span with tabindex, visibility: collapse" );

assert.isNotFocusable( "#visibilityCollapse-td", "td with tabindex, visibility: collapse" );
} );

QUnit.test( "focusable - natively focusable with various tabindex", function( assert ) {
Expand Down
2 changes: 1 addition & 1 deletion ui/focusable.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function visible( element ) {
element = element.parent();
visibility = element.css( "visibility" );
}
return visibility !== "hidden";
return visibility === "visible";
}

$.extend( $.expr.pseudos, {
Expand Down