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

[MAJOR] use attribute hidden #691

Merged
merged 2 commits into from
Oct 24, 2019
Merged

[MAJOR] use attribute hidden #691

merged 2 commits into from
Oct 24, 2019

Conversation

tinovyatkin
Copy link
Contributor

@tinovyatkin tinovyatkin commented Oct 24, 2019

You are using CSS to hide original element, while it's an exact case for global hidden attribute.
Some very cool organisations also agreed that it's a bad practice.
hidden attribute is more accessible also, as it implies aria-hidden automatically.

This also fixes bug in current version that .is-hidden was defined in optional base.scss, not in required choices.scss

@tinovyatkin tinovyatkin mentioned this pull request Oct 24, 2019
6 tasks
this.element.setAttribute('data-choice', 'active');
}

reveal() {
// Reinstate passed element
this.element.classList.remove(this.classNames.input);
this.element.classList.remove(this.classNames.hiddenState);
this.element.hidden = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it not be better to remove the attribute here?

Copy link
Contributor Author

@tinovyatkin tinovyatkin Oct 24, 2019

Choose a reason for hiding this comment

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

It's generally bad practice to mix simplified accessors (like .hidden or .tabIndex) with getAttribute/setAttribute. It does the same job, but confuses developers. For example in this case this.element.hidden = false will actually remove the attribute from DOM element, because hidden is a boolean attribute (so, there is no such thing as hidden="false" attribute)

PS: You may push something into this PR, so, GitHub Action will re-run again with Codecov coverage report (it doesn't give access to secrets for forked repositories, as mine)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah didn't realise that will remove it - fair enough 👍

@jshjohnson jshjohnson merged commit 7887c05 into Choices-js:master Oct 24, 2019
@jshjohnson
Copy link
Collaborator

Thanks :)

@tinovyatkin tinovyatkin deleted the use-hidden branch October 24, 2019 17:11
This was referenced Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants