-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Accessibility fixes for header and global elements #10310
Conversation
Could use some help with JS here on how to do the trigger using enter so that it works for all .menutoggle elements and we don’t need to change the markup. @nextcloud/javascript or what do you think? Similar for the Unable to open file or folder with keyboard #10008 issue where pressing enter on a folder/file opens the sidebar instead of opening the folder/file itself. |
64d7c4f
to
21c9054
Compare
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
ad7181d
to
b7bf2f7
Compare
This is now ready to review, together with the related Notifications pull request at nextcloud/notifications#146 Please check @nextcloud/accessibility @nextcloud/designers :) |
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.
From the point of view of the markup and script changes, it looks alright and useful, so thank you.
apps/files/js/newfilemenu.js
Outdated
|
||
// Trigger upload action also with keyboard navigation on enter | ||
this.$el.find('[for="file_upload_start"]').on('keypress', function() { | ||
$('#file_upload_start').trigger('click'); |
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.
@jancborchardt Right now this is triggered for every keypress.
Ideally, only the Enter
and Spacebar
keys should activate the functionality.
A potential fix would be something like this:
this.$el.find('[for="file_upload_start"]').on("keypress", function(event) {
if (event.key === " " || event.key === "Enter") {
$("#file_upload_start").trigger("click");
}
});
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.
@jancborchardt yup, we forgot this one! :)
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.
@kevgathuku ah right! Do you want to add a commit to the pull request? :)
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.
@jancborchardt sure. I'll add it
|
apps/files/js/newfilemenu.js
Outdated
this.$el.find('[for="file_upload_start"]').on('keypress', function() { | ||
$('#file_upload_start').trigger('click'); | ||
this.$el.find('[for="file_upload_start"]').on('keyup', function(event) { | ||
if (event.key === " " || event.key === "Enter") { |
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.
Thanks for your commit! 🎉
Why not use the codeKey?
Is there a special reason for allowing the " " ? :)
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.
Hi @skjnldsv
Thanks 👍
Why not use the codeKey?
The keyCode
is deprecated and event.key
is preferred instead.
Is there a special reason for allowing the " " ? :)
For this instance, the behavior is more like a button, which is usually activated using either the Spacebar
(" ") or Enter
keys. I'm thinking it would be better to stick to this convention.
Let me know whether this makes sense 😄
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.
Nice! Thanks for the tip, I did not know it was deprecated :)
Can you also move the edits we dit Jan and I from keyCode to key?
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.
Sure! I'll make the edits.
core/js/js.js
Outdated
// prevent the link event (append anchor to URL) | ||
event.preventDefault(); | ||
|
||
// allow enter key as a trigger | ||
if (event.keyCode && event.keyCode !== 13) { |
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 should key
instead
core/js/js.js
Outdated
$(document).on('mouseup.closemenus', function(event) { | ||
|
||
// allow enter as a trigger | ||
// if (event.keyCode && event.keyCode !== 13) { |
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 should key
instead
7df461d
to
d2e9e22
Compare
JSUnit tests fail: |
Before, the file or folder was opened when clicking on the name span, but not when clicking on the link that contains the name; clicking on the link highlighted the file and opened the sidebar, just like clicking on the file size or date. Now clicking on the link opens the file or folder, so the unit tests that tested clicks on the link were changed to test clicking on the file size instead. Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
Signed-off-by: Kevin Ndung'u <kevgathuku@gmail.com>
Signed-off-by: Kevin Ndung'u <kevgathuku@gmail.com>
d2e9e22
to
fe25092
Compare
I have amended the offending commit and fixed the JavaScript unit tests ;-) |
Thanks @skjnldsv @kevgathuku @danxuliu for the help! :) This is another great fix for better accessibility. |
Fix #9994 and fix #10008 🎉
cc @nextcloud/accessibility :)