-
Notifications
You must be signed in to change notification settings - Fork 429
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
Make the buttons
accessible.
#79
Conversation
Just a question, why do you use |
I just went with the solution that was simpler for me. Do you want to use your As for if we should change the aria attributes, I don't see the need. We only hide the icons. The label is OK I believe. |
Yeah, actually I'd use I'm not really familiar with aria spec, I just thought that |
IIRC it's OK. We do the same in Bootstrap. How about you merge this and refactor it later as you wish? |
Following the W3 ARIA spec it should be manipualted dynamically:
|
Hmm, not sure how I can keep this simple then. I'll try to check it out later and let you know. |
Ok, thanks. |
An example of grunt-accessibility in action https://travis-ci.org/mpc-hc/mpc-hc.org/builds/120297353 Now, any hints how to proceed with this? In which function should I handle the addition/removal of aria-hidden? |
Here's the line responsible for buttons visibility: |
@feimosi: so I tried this approach, but I'm having issues with inserting the new element. Check the last patch to see what I've been trying to do. |
@feimosi: I think it's better now, please check the branch and let me know so that I squash before merging. |
@XhmikosR I just don't understand, why you have created new elements [xxx]Img ? |
You asked me to use |
Ah, you're right! The name just misguided me. I'm not sure about the Img suffix.Do you have any other ideas? Maybe Content ? |
You mean |
Yeah, exactly. |
Done. I'm still not sure if we are doing the opposite with |
@@ -316,6 +325,8 @@ | |||
options.animation === 'slideIn' ? '' : 'none'); | |||
// Hide buttons if necessary | |||
if (options.buttons === 'auto' && ('ontouchstart' in window || imagesMap[currentGallery].length === 1)) { | |||
previousButtonContent.setAttribute('aria-hidden', 'true'); | |||
nextButtonContent.setAttribute('aria-hidden', 'true'); | |||
options.buttons = false; | |||
} | |||
// Set buttons style to hide or display them |
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.
Actually, I've overlooked the case when a user sets options.buttons
to false himself. The aria-hidden logic should better be on line 333. Could you insert there something like:
if (options.buttons === false) {
// set aria-hidden to true
previousButton.style.display = nextButton.style.display = 'none';
} else {
// we may also move setAttribute('aria-hidden', 'false') here
// ... .display = '';
}
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.
I agree.
But shouldn't we have aria-hidden=true
by default and aria-hidden=false
if the buttons are not hidden?
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.
We can set aria-hidden
value only in this if {} else {}
without any defaults before. What do you think?
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.
Can you check the last patch I pushed here?
BTW, the close button isn't hidden so I left it out from aria-hidden=true
.
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.
I think we need to have aria-hidden=true
by default. So, we probably need to ditch the last approach.
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.
Okay, you're right. The last patch doesn't look so good. We could move to aria-hidden=true
approach, but what about the Close button? It's always visible, so does it make sense to switch aria-hidden
for him?
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.
I guess for consistency, yes.
I pushed a 4th patch, can you look and let me know?
Does my latest code note resolve your doubts? Then we'll have 'aria logic' in one place. |
Still, I've got some mixed feelings about keeping it to Also, why don't we use |
I'm having second thoughts too :/ https://www.w3.org/TR/wai-aria/states_and_properties#aria-hidden The button is visible, the img is hidden because we have a label for assistive technologies. Which I believe should be Please look at the specs too, and we'll get to it :) |
/CC @patrickhlauke in case you have some time to chime in. |
Ok, that gets quite complicated. We have to postpone it then. I can come back to this issue during the weekend too. |
@@ -313,8 +327,19 @@ | |||
if (options.buttons === 'auto' && ('ontouchstart' in window || imagesMap[currentGallery].length === 1)) { |
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.
completely unrelated, but: am i right in thinking this test for ontouchstart
is used to determine whether or not buttons should be shown? if so, this will fall foul of touchscreen-enabled laptops/desktops and mobile/tablet devices with paired mouse/keyboard - see http://patrickhlauke.github.io/getting-touchy-presentation/
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.
Yeah, that is what this test is used for.
/CC @feimosi: maybe make a new issue to track this.
hate to ask, but...do you have a nice isolated test case showing the old and new (after applying this patch) behavior? |
having had a quick look, i think all you really want to do in this PR is to set explicit |
Cool, I'll get to it then. It baffles me that HTML_Codesniffer complains though. I'll need to check if there's any issue open upstream. |
Correction, it must be squizlabs/HTML_CodeSniffer#160. That is why I always thought I need |
Code analyzers are dumb in many cases, with many false positives/negatives depending on how complex your stuff is. To be clear, |
I know, but we need something to check things automatically too :) OK, so I'll rebase this branch and only add Thanks for all the help! |
no probs. there may be more things to fix (e.g. not checked focus handling when a lightbox is opened etc), but leave that for another day ;) |
Also switch to `×` instead of a simple `X` for the fallback close button.
@feimosi @patrickhlauke: please check for one hopefully last time. I have also added |
On a side note, it seems we need an |
LGTM at this stage |
LGTM too. |
@feimosi: not sure what you see, but the branch is already rebased. |
@XhmikosR sorry, GitHub has confused me. It shows the last commit is 10 days old and on master the last one is 6 days old. So looks like it's based on author date instead of commit date? I just want the commits to be in a chronological order aligned with PRs, so it's easier to reason about the changes. |
That is completely normal. Git is like that, and the date has no importance. |
I know how Git works. When you rebase, the commit date is updated (actually it's a new commit). That's useful to keep linear log history because after recent PRs I've noticed the log became quite a mess. |
No, the rebase alone isn't enough. I'm sorry but this is just insane. That is how things work. |
Sorry, I don't understand what you mean, what isn't enough? Correct me where I'm wrong. |
A rebase does not change the commit date. There are 2 dates, (push) date and commit date. |
Actually, there are AuthorDate and CommitDate. It's a normal practice to do a rebase before merging in feature branches workflow. I don't understand why you've resented. |
Because that is the Author Date which I don't want to change. That is when I made the patch. |
I'm just trying to say that Commit Date is more important, as it's used most of the time. You can't change Author Data and I've never asked for that. Just Github's confused me. |
Also switch to
×
instead of a simpleX
for the fallback close button.Tested things with https://github.com/squizlabs/HTML_CodeSniffer, but I think we hit squizlabs/HTML_CodeSniffer#160 for the remaining ones.