[go: up one dir, main page]

Skip to content

Commit

Permalink
Tests: Add a test for jquerygh-4950
Browse files Browse the repository at this point in the history
Focusing an input with `display: none` no longer prevents it from
being focused when it gets shown later.
  • Loading branch information
mgol committed Mar 17, 2023
1 parent 1871c3f commit 7022908
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/unit/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -3407,6 +3407,22 @@ QUnit.test( "trigger(focus) works after .on(focus).off(focus) (gh-4867)", functi
assert.equal( document.activeElement, input[ 0 ], "input has focus" );
} );

QUnit.test( "trigger(focus) works after focusing when hidden (gh-4950)", function( assert ) {
assert.expect( 1 );

var input = jQuery( "<input />" );

input.appendTo( "#qunit-fixture" );

input
.css( "display", "none" )
.trigger( "focus" )
.css( "display", "" )
.trigger( "focus" );

assert.equal( document.activeElement, input[ 0 ], "input has focus" );
} );

// TODO replace with an adaptation of
// https://github.com/jquery/jquery/pull/1367/files#diff-a215316abbaabdf71857809e8673ea28R2464
( function() {
Expand Down

0 comments on commit 7022908

Please sign in to comment.