From: vsn4ik Date: Mon, 22 Jan 2018 23:03:00 +0000 (+0300) Subject: Fix skip element disabled via attribute when using keyboard navigation X-Git-Tag: v4.1.0~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68db42c9f86fcdfcca0cc049cbde30d0d73df88a;p=thirdparty%2Fbootstrap.git Fix skip element disabled via attribute when using keyboard navigation --- diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 2f69298540..64d6b37176 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -57,7 +57,7 @@ const Dropdown = (($) => { FORM_CHILD : '.dropdown form', MENU : '.dropdown-menu', NAVBAR_NAV : '.navbar-nav', - VISIBLE_ITEMS : '.dropdown-menu .dropdown-item:not(.disabled)' + VISIBLE_ITEMS : '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)' } const AttachmentMap = { diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 3040e81b41..0e3d370413 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -544,15 +544,15 @@ $(function () { $dropdown.trigger('click') }) - QUnit.test('should skip disabled element when using keyboard navigation', function (assert) { - assert.expect(2) + QUnit.test('should focus next/previous element when using keyboard navigation', function (assert) { + assert.expect(4) var done = assert.async() var dropdownHTML = '
' + '' + '
' @@ -568,24 +568,32 @@ $(function () { $dropdown.trigger($.Event('keydown', { which: 40 })) - $dropdown.trigger($.Event('keydown', { + assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') + + $(document.activeElement).trigger($.Event('keydown', { which: 40 })) - assert.ok(!$(document.activeElement).is('.disabled'), '.disabled is not focused') + assert.ok($(document.activeElement).is($('#item2')), 'item2 is focused') + + $(document.activeElement).trigger($.Event('keydown', { + which: 38 + })) + assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') done() }) $dropdown.trigger('click') }) - QUnit.test('should focus next/previous element when using keyboard navigation', function (assert) { - assert.expect(4) + QUnit.test('should skip disabled element when using keyboard navigation', function (assert) { + assert.expect(3) var done = assert.async() var dropdownHTML = '
' + '' + '
' @@ -601,17 +609,11 @@ $(function () { $dropdown.trigger($.Event('keydown', { which: 40 })) - assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') - - $(document.activeElement).trigger($.Event('keydown', { + assert.ok($(document.activeElement).is($('#item1')), '#item1 is focused') + $dropdown.trigger($.Event('keydown', { which: 40 })) - assert.ok($(document.activeElement).is($('#item2')), 'item2 is focused') - - $(document.activeElement).trigger($.Event('keydown', { - which: 38 - })) - assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') + assert.ok($(document.activeElement).is($('#item1')), '#item1 is still focused') done() }) $dropdown.trigger('click')