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

Commit fd2653b

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 685b892 commit fd2653b

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
@@ -3396,6 +3396,22 @@ QUnit.test( "trigger(focus) works after .on(focus).off(focus) (gh-4867)", functi
33963396
assert.equal( document.activeElement, input[ 0 ], "input has focus" );
33973397
} );
33983398

3399+
QUnit.test( "trigger(focus) works after focusing when hidden (gh-4950)", function( assert ) {
3400+
assert.expect( 1 );
3401+
3402+
var input = jQuery( "<input />" );
3403+
3404+
input.appendTo( "#qunit-fixture" );
3405+
3406+
input
3407+
.css( "display", "none" )
3408+
.trigger( "focus" )
3409+
.css( "display", "" )
3410+
.trigger( "focus" );
3411+
3412+
assert.equal( document.activeElement, input[ 0 ], "input has focus" );
3413+
} );
3414+
33993415
// TODO replace with an adaptation of
34003416
// https://github.com/jquery/jquery/pull/1367/files#diff-a215316abbaabdf71857809e8673ea28R2464
34013417
( function() {

0 commit comments

Comments
 (0)