Skip to content

Commit 86a958d

Browse files
committed
Core: Update :focsable and :tabbable to handle parents with no height/width, but visible overflow. Fixes #8643 - :focusable pseudo-selector does not find elements if parent has 0x0 dimension.
1 parent 97b4813 commit 86a958d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

tests/unit/core/core.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ <h2 id="qunit-userAgent"></h2>
112112
<span id="spanTabindex-50" tabindex="-50">.</span>
113113
</div>
114114

115+
<div style="width: 0; height: 0;">
116+
<input id="dimensionlessParent">
117+
<input id="dimensionlessParent-dimensionless" style="height: 0; width: 0;">
118+
</div>
119+
115120
<div id="zIndex100" style="z-index: 100; position: absolute">
116121
<div id="zIndexAutoWithParent">.</div>
117122
</div>

tests/unit/core/selector.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ test("focusable - area elements", function() {
157157
isNotFocusable('#areaNoImg', 'not associated with an image');
158158
});
159159

160+
test( "focusable - dimensionless parent with overflow", function() {
161+
expect( 1 );
162+
163+
isFocusable( "#dimensionlessParent", "input" );
164+
});
165+
160166
test("tabbable - visible, enabled elements", function() {
161167
expect(18);
162168

@@ -236,4 +242,10 @@ test("tabbable - area elements", function() {
236242
isNotTabbable('#areaNoImg', 'not associated with an image');
237243
});
238244

245+
test( "tabbable - dimensionless parent with overflow", function() {
246+
expect( 1 );
247+
248+
isTabbable( "#dimensionlessParent", "input" );
249+
});
250+
239251
})(jQuery);

ui/jquery.ui.core.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ function focusable( element, isTabIndexNotNaN ) {
198198
}
199199

200200
function visible( element ) {
201-
return !$( element ).parents().andSelf().filter(function() {
202-
return $.css( this, "visibility" ) === "hidden" ||
203-
$.expr.filters.hidden( this );
204-
}).length;
201+
return $.expr.filters.visible( element ) &&
202+
!$( element ).parents().andSelf().filter(function() {
203+
return $.css( this, "visibility" ) === "hidden";
204+
}).length;
205205
}
206206

207207
$.extend( $.expr[ ":" ], {

0 commit comments

Comments
 (0)