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

[4.2] [GSoC 21] Keyboard-Shortcut Plugin #38092

Merged
merged 208 commits into from
Jun 22, 2022
Merged

Conversation

fancyFranci
Copy link
Contributor

@fancyFranci fancyFranci commented Jun 19, 2022

Summary of Changes

This is a new plugin, developed in the GSoC 21 Accessibility project.

It introduces keyboard shortcuts to the administrator site like pressing J + F to jump into the search field or J + S to save. Other extensions are able to add their shortcuts as well by hooking in on the onLoadShortcuts event. All(!) of them are listed in a modal window, which shows up by pressing J + X.

The current state is just the start. Further steps would be the editing of shortcuts, the possibility to disable them, changing the overview-text-hint to a button in the corner etc. The editing was there already but it had some flaws, so it will come later (without flaws) :)

Thanks to @Krshivam25 the student behind this GSoC project, @chmst, @bembelimen, and @brianteeman for alle the work and feedback!

Testing Instructions

Make sure the shortcut plugin is enabled and start by pressing J + X (in sequence, not at the same time!) for the overview. Have a look at the hint, which tells you the same at the bottom of the page. Then visit different pages and try out the shortcuts :)

If your motivated you can let your plugin add new shortcuts and test them! Add "onLoadShortcuts" to the getSubscribedEvents and write something like this:

public function onLoadShortcuts(EventInterface $event): void {
   $shortcuts = $event->getArgument('shortcuts');
   $testShortcuts = array('test' => (object)['shortcut' => 'J + T', 'title' => 'Great Test', 'selector' => '#menu-collapse']);
   $event->setArgument('shortcuts',  array_merge($shortcuts, $testShortcuts));
}

Actual result BEFORE applying this Pull Request

You needed to click on buttons to do something

Expected result AFTER applying this Pull Request

You can use your keyboard to do something (besides typing text)

Documentation Changes Required

Yes, I will create a page to describe the build up of the shortcuts, how extensions can add them and what the default joomla shortcuts are. Part of it would be:

The 3rd party plugin needs to provide an array of shortcuts which are objects:
{ shortcut: string, selector: string, title: string }
The shortcut needs to be a keyboard input, separated by a plus e.g. "J + Y" or "ALT + Z + 7" (currently there is really no filtering).
Selectors are like CSS selectors to target an element. When it is an input element, the shortcut gives focus, otherwise it will be clicked.
The Title will be displayed in the overview. It could be the name of the target.

@bembelimen
Copy link
Contributor

I have tested this item ✅ successfully on b223844


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38092.

@chmst
Copy link
Contributor

chmst commented Jun 21, 2022

I have tested this item ✅ successfully on b223844

Great!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38092.

@brianteeman
Copy link
Contributor

Grrrh. Using a keyboard sequence doesnt seem to work as I expected. It doesnt work at all in NVDA or Windows Narrator.

In both cases the combination J + X tries to go to the next checkbox.

@fancyFranci
Copy link
Contributor Author

Grrrh. Using a keyboard sequence doesnt seem to work as I expected. It doesnt work at all in NVDA or Windows Narrator.
In both cases the combination J + X tries to go to the next checkbox.

Sorry, that one got lost in all the comments. I'll have a look on that, maybe preventing defaults after J was pressed (not X alone) could be enough.

@Quy
Copy link
Contributor

Quy commented Jun 21, 2022

I find the legend in the footer a little distracting. My focus draws to it. It is useful in the beginning but I can see it becoming annoying after a while.

shortcut-footer

@brianteeman
Copy link
Contributor

jx is a dl but the description in the plugin is a ul

@fancyFranci
Copy link
Contributor Author

I find the legend in the footer a little distracting. My focus draws to it. It is useful in the beginning but I can see it becoming annoying after a while.

Now the hint only appears on cpanel-pages like the home dashboard. As you said - its only useful at the beginning

@fancyFranci
Copy link
Contributor Author

Grrrh. Using a keyboard sequence doesnt seem to work as I expected. It doesnt work at all in NVDA or Windows Narrator.
In both cases the combination J + X tries to go to the next checkbox.

It seems like NVDA interrupt the keyboard input before js can do/prevent anything. Even when I change the shortcuts to something NVDA does not use, nothing happens besides making a sound. When we configure modifiers like ALT, they do not work in sequence because the browser interrupts (at least in my tests). What do you think @brianteeman ? :/

@brianteeman
Copy link
Contributor

(not at my pc to test) what happens on github when you use nvda and the github shortcuts?

@fancyFranci
Copy link
Contributor Author

fancyFranci commented Jun 22, 2022

I tried out s for githubs search and I'm not jumping into the search field as long as nvda is running. Same with g and n, which should normally open notifications.

@fancyFranci
Copy link
Contributor Author

...but the command palette (which opens on ctrl+k) works with nvda

@brianteeman
Copy link
Contributor

It looks like its a known issue with the nvda single character shortcuts
https://www.nvaccess.org/files/nvda/documentation/userGuide.html#SingleLetterNavigation

@brianteeman
Copy link
Contributor

yes looks like this is one of those cases where a real screen reader user knows what to do.

"In browse mode, you can now toggle single letter navigation on and off by pressing NVDA+shift+space. When off, single letter keys are passed to the application, which is useful for some web applications such as Gmail, Twitter and Facebook."

or you switch from browse to focus mode.

Havng read the nvda manual link I am happy enough that the current code is ok to merge

@fancyFranci fancyFranci merged commit febdab6 into joomla:4.2-dev Jun 22, 2022
@fancyFranci
Copy link
Contributor Author

Thanks everybody! :)

@brianteeman
Copy link
Contributor

thank you all.

Cant wait to read the docs how this can be extended by extensions

@fancyFranci
Copy link
Contributor Author

I wrote an example in the test instructions which I used myself to test added shortcuts. But yes, docs will follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Change This is for Translators NPM Resource Changed This Pull Request can't be tested by Patchtester
Projects
None yet
Development

Successfully merging this pull request may close these issues.