🌐 AI搜索 & 代理 主页
Skip to content

Commit f5b7dc0

Browse files
committed
Tests: Add a test for gh-4950
Focusing an input with `display: none` no longer prevents it from being focused when it gets shown later.
1 parent 934bc7e commit f5b7dc0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/unit/event.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,22 @@ QUnit.test( "trigger(focus) works after .on(focus).off(focus) (gh-4867)", functi
34073407
assert.equal( document.activeElement, input[ 0 ], "input has focus" );
34083408
} );
34093409

3410+
QUnit.test( "trigger(focus) works after focusing when hidden (gh-4950)", function( assert ) {
3411+
assert.expect( 1 );
3412+
3413+
var input = jQuery( "<input />" );
3414+
3415+
input.appendTo( "#qunit-fixture" );
3416+
3417+
input
3418+
.css( "display", "none" )
3419+
.trigger( "focus" )
3420+
.css( "display", "" )
3421+
.trigger( "focus" );
3422+
3423+
assert.equal( document.activeElement, input[ 0 ], "input has focus" );
3424+
} );
3425+
34103426
// TODO replace with an adaptation of
34113427
// https://github.com/jquery/jquery/pull/1367/files#diff-a215316abbaabdf71857809e8673ea28R2464
34123428
( function() {

0 commit comments

Comments
 (0)