Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

fix(fab-speed-dial): action items are in tab order when closed #12067

Merged
merged 1 commit into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/fabActions/fabActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -45,5 +51,4 @@
}
};
}

})();
17 changes: 17 additions & 0 deletions src/components/fabActions/fabActions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ describe('<md-fab-actions> 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(
'<md-fab-speed-dial>' +
' <md-fab-actions>' +
' <md-button>1</md-button>' +
' <md-button>2</md-button>' +
' <md-button>3</md-button>' +
' </md-fab-actions>' +
'</md-fab-speed-dial>'
);

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(
Expand Down