Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aria warnings in Chrome lighthouse, make aria spec compliant #197

Merged
merged 14 commits into from
Feb 9, 2020

Conversation

mattywong
Copy link
Contributor

closes #195 + more additional fixes to get this lighthouse/spec compliant

aria-readonly attr on input has been removed - Not sure why it was added in the first place? According to w3 aria spec (http://w3c.github.io/html-aria/#index-aria-combobox) readonly and aria-readonly properties can't be used when role="combobox". This aria-readonly attr also shows an error in lighthouse aria validation.

remove initial empty aria-activedescendant (aria-activedescendant="") - This seems to go against the spec also (see w3c/aria#501 and validator/validator#557) and also shows an error in lighthouse aria validation.

add correct aria-owns id reference, and if no id is present on input, generate a guid from helpers and attach to menu - this fixes the issue outlined in #195, the previous change for this (line 45) never worked as it was referencing 'www.menu' which never exists, and even with the correct reference 'www.selectors.menu' also wouldn't have worked as it would've just changed all the menus ('.tt-menu') the the last input id that was initialised

@jlbooker
Copy link
Contributor

Hi @mattywong, Thanks for the PR. It looks like there's a fair number of unit tests that broke with this, though. Check the TravisCI job for the full list. I don't think this can be merged with that many. Could you work on those and update this PR?

Also, you'll notice the files in dist/* are now conflicting. That's not a big deal, it just means the project has been rebuilt since you committed. For future PRs, you'll see fewer merge conflicts if you don't commit the dist/* files.

@@ -333,6 +333,7 @@ var Typeahead = (function() {

open: function open() {
if (!this.isOpen() && !this.eventBus.before('open')) {
this.input.$input.attr("aria-expanded", true);
Copy link
Contributor

Choose a reason for hiding this comment

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

I have noticed your tests are broken because $input is not available in this context, if possible create the function bellow at input.js and call it here to set aria-expanded. This will fix all the broken tests.

setAriaExpanded: function setAriaExpanded(value) {
    this.$input.attr('aria-expanded', value);
},

@@ -343,6 +344,7 @@ var Typeahead = (function() {

close: function close() {
if (this.isOpen() && !this.eventBus.before('close')) {
this.input.$input.attr("aria-expanded", false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I have noticed your tests are broken because $input is not available in this context, if possible create the function bellow at input.js and call it here to set aria-expanded. This will fix all the broken tests.

setAriaExpanded: function setAriaExpanded(value) {
    this.$input.attr('aria-expanded', value);
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@juliano-nunes juliano-nunes left a comment

Choose a reason for hiding this comment

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

Please rebase your branch with master

@@ -333,6 +333,7 @@ var Typeahead = (function() {

open: function open() {
if (!this.isOpen() && !this.eventBus.before('open')) {
this.input.setAriaExpanded(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should set to true here.

@juliano-nunes
Copy link
Contributor

I think you have merged master in your branch instead of rebase it, which is not a good practice. It would be nice if you rebase your branch instead of merge, if you need help, this article can help.

Also, it seems your updates are not in dist files, could you run grunt build and commit the dist files?

@juliano-nunes
Copy link
Contributor

Hey @mattywong, I have created a new Pull Request (#203) to make some tests and I figured out that we just have to upgrade Node version in travis.yml to solve this. I have tested with v10.18.0 and it was just fine, can you apply this change?

package.json Outdated
@@ -71,6 +71,6 @@
"scripts": {
"test": "bower install && node ./node_modules/karma/bin/karma start --single-run --browsers PhantomJS"
},
"version": "1.3.0",
"version": "1.2.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update to the next minor and regenerate build files, please?

Suggested change
"version": "1.2.3",
"version": "1.3.1",

package.json Outdated
"main": "dist/typeahead.bundle.js"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}

package.json Outdated Show resolved Hide resolved
@juliano-nunes
Copy link
Contributor

@jlbooker I think that we can merge this one when @mattywong resolve my last review. Is that possible?

Co-Authored-By: Juliano Marques Nunes <julianomarquesnunes@gmail.com>
@jlbooker jlbooker merged commit 77c43a7 into corejavascript:master Feb 9, 2020
@jlbooker jlbooker added this to the 1.3.1 milestone Feb 9, 2020
@jlbooker
Copy link
Contributor

This has been released as part of v1.3.1.

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

Successfully merging this pull request may close these issues.

aria warnings in lighthouse for input element
3 participants