This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(ngAria): clean up tabindex usage #12262
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,10 +616,35 @@ describe('$aria', function() { | |
describe('tabindex', function() { | ||
beforeEach(injectScopeAndCompiler); | ||
|
||
it('should attach tabindex to role="checkbox", ng-click, and ng-dblclick', function() { | ||
it('should not attach to native controls', function() { | ||
var element = [ | ||
$compile("<button ng-click='something'></button>")(scope), | ||
$compile("<a ng-href='#/something'>")(scope), | ||
$compile("<input ng-model='val'>")(scope), | ||
$compile("<textarea ng-model='val'></textarea>")(scope), | ||
$compile("<select ng-model='val'></select>")(scope), | ||
$compile("<details ng-model='val'></details>")(scope) | ||
]; | ||
expectAriaAttrOnEachElement(element, 'tabindex', undefined); | ||
}); | ||
|
||
it('should not attach to random ng-model elements', function() { | ||
compileElement('<div ng-model="val"></div>'); | ||
expect(element.attr('tabindex')).toBeUndefined(); | ||
}); | ||
|
||
it('should attach tabindex to custom inputs', function() { | ||
compileElement('<div type="checkbox" ng-model="val"></div>'); | ||
expect(element.attr('tabindex')).toBe('0'); | ||
|
||
compileElement('<div role="checkbox" ng-model="val"></div>'); | ||
expect(element.attr('tabindex')).toBe('0'); | ||
|
||
compileElement('<div type="range" ng-model="val"></div>'); | ||
expect(element.attr('tabindex')).toBe('0'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided Angular and ngAria shouldn't be in the business of fixing custom radiogroups...it's too big of a can of worms when it comes to expected keyboard behavior. |
||
}); | ||
|
||
it('should attach to ng-click and ng-dblclick', function() { | ||
compileElement('<div ng-click="someAction()"></div>'); | ||
expect(element.attr('tabindex')).toBe('0'); | ||
|
||
|
@@ -640,26 +665,6 @@ describe('$aria', function() { | |
compileElement('<div ng-dblclick="someAction()" tabindex="userSetValue"></div>'); | ||
expect(element.attr('tabindex')).toBe('userSetValue'); | ||
}); | ||
|
||
it('should set proper tabindex values for radiogroup', function() { | ||
compileElement('<div role="radiogroup">' + | ||
'<div role="radio" ng-model="val" value="one">1</div>' + | ||
'<div role="radio" ng-model="val" value="two">2</div>' + | ||
'</div>'); | ||
|
||
var one = element.contents().eq(0); | ||
var two = element.contents().eq(1); | ||
|
||
scope.$apply("val = 'one'"); | ||
expect(one.attr('tabindex')).toBe('0'); | ||
expect(two.attr('tabindex')).toBe('-1'); | ||
|
||
scope.$apply("val = 'two'"); | ||
expect(one.attr('tabindex')).toBe('-1'); | ||
expect(two.attr('tabindex')).toBe('0'); | ||
|
||
dealoc(element); | ||
}); | ||
}); | ||
|
||
describe('accessible actions', function() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[]
here is a placeholder for forthcomingng-disabled
improvements. This PR is purposefully limited.