-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(ngAria): clean up tabindex usage #12262
Conversation
@@ -126,6 +128,11 @@ function $AriaProvider() { | |||
}; | |||
} | |||
|
|||
function isNodeOneOf(elem, nodeTypeArray) { |
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.
This function used to live inside of the ngClick
override directive, below. This exposes it to the entire module.
I don't know why/if it should not be user-configurable, but putting it onto the service makes it user-configurable. Not sure if it's for better or worse, but you could use the |
Good point...I swapped that around at the last minute and didn't think it through. Two things:
|
Interactive roles are:
|
It is indeed difficult/undesirable to refactor something, once it's been made public. I would refrain from it for now and re-consider if/when we have several users asking for it. Especially, since
All modules are wrapped in an IIFE, so you will not be polluting the global scope. |
@patrickfox so glad to hear your take on it! I definitely don't think For If we take a step back and look at what people expect from ngAria, it's to get accessibility for free: e.g. "I include this module, it makes my app accessible". Just including the module isn't enough, however–most of the time you also have to add a This last question I think about a lot when adding features to ngAria–I don't think an Angular module should encourage ARIA patterns like |
I should add, I have another PR forthcoming to limit ARIA usage on native controls, since right now they introduce redundancy. For example, native inputs currently get |
c37c8a8
to
25769e8
Compare
Okay, I finally got your feedback incorporated @gkalpak. I considered @patrickfox's points about interactive roles, but decided to keep the logic as-is. ngAria already checks for some of those roles under the hood for ngModel before adding tabindex (checkbox, radio, etc.)–it compares those roles against a |
@@ -226,7 +235,7 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) { | |||
} | |||
}, | |||
post: function(scope, elem, attr, ngModel) { | |||
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem); | |||
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem, nodeBlackList); |
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.
shouldAttachAttr()
does not take nodeBlackList
into account. I think ti should...
(Either take it into account or remove this 4th argument - to avoid confusion.)
It LGTM (with the exception of little comment regarding I am wondering if there should be a BREAKING CHANGE notice about not trying to |
* Do not put tabindex on native controls using ng-model or ng-click * Uses a single nodeBlacklist to limit which elements receive support Closes angular#11500
25769e8
to
fd15b73
Compare
@gkalpak I removed The radiogroup reference was only in a test, there is no change to the code. So I don't think it's a breaking change. |
@marcysutton, I don't think the
Good point 😄 No breaking change then ! |
The check that it does is a bit weird, to be honest...the fact that it checks for It reminds me of the bugs I uncovered with Do you think we can kill the |
I am not sure how much of a breaking change it would be. Since this is on the 1.4.x milestone, we shouldn't introduce significantly different behaviour. If you think it will not break stuff (much), I'd say go for it. Else, let's improve what can be "backwards compatibly" improved and defer bigger changes to 1.5.x. |
Ok, I think it's worth keeping it as-is for now and swapping the |
@marcysutton, is this PR ready for final review/merging ? |
@gkalpak yup! I think it should stay as-is until the next PR, which I can start as soon as this is merged. |
LGTM |
1 similar comment
LGTM |
tabindex
on natively interactive controls usingng-model
orng-click
nodeBlacklist
to limit which elements receive support (not user-configurable)Closes #11500