From 9997aeabada181733726b86ecb0bafb106a75885 Mon Sep 17 00:00:00 2001 From: Michael Prentice Date: Thu, 17 Dec 2020 07:16:55 -0500 Subject: [PATCH] fix(fab-speed-dial): action items are in tab order when closed - apply `tabindex="-1"` to all `md-button`s in the `md-fab-actions` Fixes #10101 --- src/components/fabActions/fabActions.js | 9 +++++++-- src/components/fabActions/fabActions.spec.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/fabActions/fabActions.js b/src/components/fabActions/fabActions.js index 101d0f983a5..0b801a7ca64 100644 --- a/src/components/fabActions/fabActions.js +++ b/src/components/fabActions/fabActions.js @@ -32,9 +32,15 @@ compile: function(element, attributes) { var children = element.children(); - + var actionItemButtons; var hasNgRepeat = $mdUtil.prefixer().hasAttribute(children, 'ng-repeat'); + // Action item buttons should not be in the tab order when the speed dial is closed. + actionItemButtons = element.find('md-button'); + angular.forEach(actionItemButtons, function(button) { + button.setAttribute('tabindex', -1); + }); + // Support both ng-repeat and static content if (hasNgRepeat) { children.addClass('md-fab-action-item'); @@ -45,5 +51,4 @@ } }; } - })(); diff --git a/src/components/fabActions/fabActions.spec.js b/src/components/fabActions/fabActions.spec.js index ff370d5d176..13f499cdc2b 100644 --- a/src/components/fabActions/fabActions.spec.js +++ b/src/components/fabActions/fabActions.spec.js @@ -29,6 +29,23 @@ describe(' directive', function() { expect(element.find("md-fab-actions").children()).toHaveClass('md-fab-action-item'); })); + it('applies tabindex of -1 to all action item buttons', inject(function() { + build( + '' + + ' ' + + ' 1' + + ' 2' + + ' 3' + + ' ' + + '' + ); + + expect(element.find("md-button").length).toBe(3); + angular.forEach(element.find("md-button"), function(button) { + expect(button.getAttribute('tabindex')).toEqual('-1'); + }); + })); + angular.forEach(['ng-repeat', 'data-ng-repeat', 'x-ng-repeat'], function(attr) { it('supports actions created by ' + attr, inject(function() { build(