Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngAria): handle custom elements with role="checkbox" #11321

Closed
wants to merge 1 commit into from

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Mar 13, 2015

In d6eba21#diff-91e9129201746ba107348c9a0a7735edR218, we fixed some issues with checkboxes with string and integer models using ngTrueValue / ngFalseValue, but I did not take into consideration custom role="checkbox" elements (as in the ngAria docs). They are currently broken, because the new way of checking "checkedness" is by using ngModel.$isEmpty, which has a special implementation for checkboxes. Custom elements obviously lack this.
My idea is to provide the checkbox $isEmpety implementation as a default to all elements that come with role="checkbox" in the preLink fn. It can then be overwritten by the custom implementation. (since ngAria is simply assuming that a custom checkbox will have a boolean checkstate, which might not be the case).

@marcysutton can you have a look at this?

getRadioReaction() : ngAriaCheckboxReaction);
return {
pre: function(scope, elem, attr, ngModel) {
if (shape === 'checkbox' && attr.role === 'checkbox') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hasn't getShape already checked for role="checkbox"? Also, will shimming ngModel.$isEmpty for custom checkboxes affect native ones at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true; I was looking for a way to set $isEmpty only for elements that are not inputs. There's probably a better way to do it.

@marcysutton
Copy link
Contributor

@Narretz this looks great. thanks for doing the work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants