Feature NPM Resource Changed PR-5.0-dev PR-5.3-dev
avatar HLeithner
HLeithner
30 Aug 2023

Summary of Changes

Add the possibility for toolbars (and theoretically any html element) to hide and unhide if a modifier key is pressed.

Supported modifier keys:

  • AltLeft
  • AltRight
  • ControlLeft
  • ControlRight
  • CapsLock
  • ShiftLeft
  • ShiftRight
  • MetaLeft
  • MetaRight
  • Alt Extends to AltLeft and AltRight and AltGraph
  • AltGraph Extends to AllRight and Alt
  • Control Extends to ControlLeft and ControlRight
  • Shift Extends to CapsLock and ShiftLeft and ShiftRight
  • Meta Extends to MetaLeft and MetaRight

2 new accessors has been added to the toolbar buttons:

  • alternativeGroup - Holds a unique identifier for linked buttons
  • alternativeKeys - Holds a comma separated list

Example usage:

$toolbar->trash('articles.trash')
    ->listCheck(true)
    ->alternativeGroup('trash')
    ->alternativeKeys('Default');

$toolbar->delete('articles.delete', 'JTOOLBAR_DELETE')
    ->alternativeGroup('trash')
    ->alternativeKeys('Shift')
    ->message('JGLOBAL_CONFIRM_DELETE')
    ->listCheck(true);

The example above creates a Trash button which is shown when no modifier is pressed and a Delete button which is only shown when one of the both Shift (Left or Right) is pressed or the CapsLock as been activated.

The change happens only when the relevant browser window has the focus.

Possible additional functionally

  • Support for buttonsRoll and Num
  • Support button combinations

Testing Instructions

As example I created a Trash/Delete switch in articles overview and a switch for the Save button in articles edit view.

  • open articles overview
  • click new article
  • add title
  • press the Shift key -> Save Button changes to "Save & New" (That's only an example, maybe removed)
  • save the article
  • at the article overview select the created article
  • click on the "action" toolbar dropdown
  • pressing the Shift will change the Trash button to an Delete button

Actual result BEFORE applying this Pull Request

Trash and Save of articles work

Expected result AFTER applying this Pull Request

Trash and Save of articles still work, but additional with pressed Shift button you can directly deleted an article.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • Pull Request link for manual.joomla.org:

avatar HLeithner HLeithner - open - 30 Aug 2023
avatar HLeithner HLeithner - change - 30 Aug 2023
Status New Pending
avatar brianteeman
brianteeman - comment - 30 Aug 2023

ah - now I understand your earlier question. Not quite what I understood before.

For clarification can you confirm that this is not modifer + keypress but modifier +mouseclick

The former is accessible - the latter is probably not.

avatar joomla-cms-bot joomla-cms-bot - change - 30 Aug 2023
Category Administration com_content Repository NPM Change JavaScript Layout Libraries
avatar HLeithner
HLeithner - comment - 30 Aug 2023

Pressing CapsLock works as you expect (not holding), all other buttons work like everywhere else with keeping it pressed and mouse click. We will not use this in code of course, so only "Shift" will work for us.

avatar brianteeman
brianteeman - comment - 30 Aug 2023

So impossible to use without a mouse then

avatar HLeithner
HLeithner - comment - 30 Aug 2023

nope works also without a mouse, not perfect because the focus is not set to the unhidden button which is a bit uncool with shift pressed (because moves backward) but works, also if you press CapsLock normal tapping works.

For all other keys the operating system has Sticky Keys functionality which holds the pressed for you.

avatar HLeithner HLeithner - change - 30 Aug 2023
Labels Added: Feature NPM Resource Changed PR-5.0-dev
avatar HLeithner
HLeithner - comment - 30 Aug 2023

now the focus should be preserved

avatar brianteeman
brianteeman - comment - 30 Aug 2023

Really not a fan of this.

  1. When using the caps lock as the modifier this only works when you turn on the caps lock. If you already have caps lock on then you have to turn it off and then turn it back on to work. perhaps a bug that can be fixed?

  2. For it to be implemented then every component model and view needs to be updated - you would want the delete/trash functionality consistently available otherwise its bad ux

  3. The save example is really confusing as its only active on a NEW article and not an existing article. Without this PR saving the article only adds buttons to the toolbar. With this PR it changes the buttons. That is both confusing and an accessibility fail

  4. You lose the ability to just save an article with the caps lock on - perhaps a bug that can be fixed?

  5. When I said can't be used without a mouse I should have been more explcit and said almost impossible to use on a touch device

  6. The list of modifier keys is confusing as it implies they are all different keys but in reality many of them are pairs (or at least they are on a uk windows keyboard layout) where for example there is no difference between controlLeft and controlRight

avatar HLeithner
HLeithner - comment - 30 Aug 2023

Really not a fan of this.

  1. When using the caps lock as the modifier this only works when you turn on the caps lock. If you already have caps lock on then you have to turn it off and then turn it back on to work. perhaps a bug that can be fixed?

That might be possible the question if needed. Would need a periodic check but maybe there is an event for it @Fedik @dgrammatiko ?

  1. For it to be implemented then every component model and view needs to be updated - you would want the delete/trash functionality consistently available otherwise its bad ux

of course

  1. The save example is really confusing as its only active on a NEW article and not an existing article. Without this PR saving the article only adds buttons to the toolbar. With this PR it changes the buttons. That is both confusing and an accessibility fail

Yeah the save example was only a quick shot, wasn't the best idea tbh but already invested way too much time in this feature.

  1. You lose the ability to just save an article with the caps lock on - perhaps a bug that can be fixed?

as said only a prove of concept and need to be done much better

  1. When I said can't be used without a mouse I should have been more explcit and said almost impossible to use on a touch device

different devices needs different input paradigmatic so I don't see that as a problem, we also have things for mobil devices which are useless for desktop systems.

  1. The list of modifier keys is confusing as it implies they are all different keys but in reality many of them are pairs (or at least they are on a uk windows keyboard layout) where for example there is no difference between controlLeft and controlRight

you don't have 2 control keys? The reason for the "control" and "shift" names I used to have it simple for the developer but still be possible to do special things if needed. Of course that's not things for core, here I would stick to Shift and Ctrl, the rest is a bit fishy.

avatar brianteeman
brianteeman - comment - 30 Aug 2023

you don't have 2 control keys?

yes I do but they both issue the same keycode

avatar HLeithner
HLeithner - comment - 30 Aug 2023

The Browser nows the difference ;)

avatar dgrammatiko
dgrammatiko - comment - 31 Aug 2023

FWIW Web Components/Custom Elements are a better fit here. Pass the methods, labels, etc and do everything in the JS, it doesn't need to prerender the actual buttons server side (also I don't think the approach of 2 buttons, one hidden is reflecting best practices).

My 2c

avatar HLeithner
HLeithner - comment - 31 Aug 2023

No real difference when I look at the toolbarbutton htmlmarkup then i See it's mostly rendered in the layout file. Beside that, in the current form it's agnostic and could be used for every element. But of course I'm not the js master

avatar Fedik
Fedik - comment - 31 Aug 2023

I have made a PR with litle changes, check your clone.

avatar HLeithner
HLeithner - comment - 30 Sep 2023

This pull request has been automatically rebased to 5.1-dev.

avatar HLeithner
HLeithner - comment - 24 Apr 2024

This pull request has been automatically rebased to 5.2-dev.

avatar HLeithner HLeithner - change - 24 Apr 2024
Title
[5.0] Add support for alternative buttons on modifier key pressed.
[5.2] Add support for alternative buttons on modifier key pressed.
avatar HLeithner HLeithner - edited - 24 Apr 2024
avatar HLeithner
HLeithner - comment - 2 Sep 2024

This pull request has been automatically rebased to 5.3-dev.

avatar HLeithner HLeithner - change - 2 Sep 2024
Title
[5.2] Add support for alternative buttons on modifier key pressed.
[5.3] Add support for alternative buttons on modifier key pressed.
avatar HLeithner HLeithner - edited - 2 Sep 2024
avatar richard67 richard67 - change - 15 Sep 2024
Labels Added: PR-5.3-dev

Add a Comment

Login with GitHub to post a comment