From 37b20870e961974c54772600f33f3ef66dd9faa8 Mon Sep 17 00:00:00 2001 From: gildas bescond Date: Mon, 21 Dec 2015 14:30:41 +0100 Subject: [PATCH] fix(components): dropdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit focus du première element et ajout des role --- js/src/dropdown.js | 15 ++++++++++++--- js/tests/visual/dropdown.html | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/js/src/dropdown.js b/js/src/dropdown.js index f947d2aa11..e4c2a11f6d 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -109,11 +109,15 @@ const Dropdown = (($) => { return false } - this.focus() + //this.focus() this.setAttribute('aria-expanded', 'true') - + + + // patch to select by default first item + $(parent).toggleClass(ClassName.OPEN) $(parent).trigger($.Event(Event.SHOWN, relatedTarget)) + $(this).parent().find('.dropdown-menu a:first-child').focus() return false } @@ -203,6 +207,7 @@ const Dropdown = (($) => { } static _dataApiKeydownHandler(event) { + console.log('_dataApiKeydownHandler') if (!/(38|40|27|32)/.test(event.which) || /input|textarea/i.test(event.target.tagName)) { return @@ -259,7 +264,11 @@ const Dropdown = (($) => { } - + // set default acessibility Attributes + $( document ).ready( function () { + $('.dropdown-menu').attr('role','menu') + $('.dropdown-menua a.dropdown-item').attr('role','menuitem') + }) /** * ------------------------------------------------------------------------ * Data Api implementation diff --git a/js/tests/visual/dropdown.html b/js/tests/visual/dropdown.html index f0d6f159e0..964df17e50 100644 --- a/js/tests/visual/dropdown.html +++ b/js/tests/visual/dropdown.html @@ -22,13 +22,13 @@

Dropdown Bootstrap Visual Test