83566[TASK] Make dashboard editable via keyboard
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 13
- Build/Sources/Sass/dashboard/_grid.scss3+5 −0
- Build/Sources/Sass/dashboard/_widget.scss+4 −2
- Build/Sources/TypeScript/dashboard/grid.ts+7 −0
- Build/Sources/TypeScript/dashboard/widget-keyboard-control.ts37new+206 −0
- Build/Sources/TypeScript/dashboard/widget-remover.ts+1 −1
- typo3/sysext/dashboard/Classes/Controller/DashboardController.php+6 −0
- typo3/sysext/dashboard/Resources/Private/Language/locallang.xlf2+24 −0
- typo3/sysext/dashboard/Resources/Private/Layouts/Widget/Widget.html+1 −1
- typo3/sysext/dashboard/Resources/Private/Templates/Dashboard/Main.html+27 −13
- typo3/sysext/dashboard/Resources/Public/Css/dashboard.css+3 −2
- typo3/sysext/dashboard/Resources/Public/JavaScript/grid.js+1 −1
- typo3/sysext/dashboard/Resources/Public/JavaScript/widget-keyboard-control.jsnew+13 −0
- typo3/sysext/dashboard/Resources/Public/JavaScript/widget-remover.js+1 −1
Review log 3955
Show 2030 earlier messages
-
Willi Wehmeier uploaded patch set 1 03/22/24, 07:50
-
Willi Wehmeier marked it work in progress 03/22/24, 07:51
-
core-ci voted on patch set 1 V -1 03/22/24, 07:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54831
-
Willi Wehmeier rebased onto patch set 2
V -104/02/24, 06:26 -
core-ci voted on patch set 2 V -1 04/02/24, 06:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55123
-
Willi Wehmeier uploaded patch set 3
V -104/08/24, 06:39 -
core-ci voted on patch set 3 V -1 04/08/24, 06:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55535
-
Willi Wehmeier uploaded patch set 4
V -104/08/24, 07:22 -
core-ci voted on patch set 4 V +1 04/08/24, 07:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55537
-
Willi Wehmeier uploaded patch set 5
V +104/09/24, 05:21 -
core-ci voted on patch set 5 V +1 04/09/24, 05:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55588
-
Willi Wehmeier marked it ready for review 04/09/24, 05:35
-
Ayke Halder commented on patch set 5 04/10/24, 16:34
Great job here to make this work! I have some minor issues which might be fixable, please have a look._grid.scss:72In Firefox it only correctly styles preceding elements when the asterisk is removed: `.dashboard-item:has(~ .js-dashboard-item-focused)` Also see: https://developer.mozilla.org/en-US/docs/Web/CSS/:has#csswidget-keyboard-control.ts:93May we somehow re-focus the drag-button of the `selectedElement`. So after moving an element we keep the focus on this element. Or does focusing the drag-button stop screenreaders from reading out the text from `ariaLiveSelector`? -
Ayke Halder commented on patch set 5 04/10/24, 16:58
Another point about using 'Escape' and 'Tab' while moving is active.widget-keyboard-control.ts:62Maybe add some more actions while an element is selected: * The 'Escape' button should stop the move action and restore the order as before. * Other keys should not work anymore - but especially 'Tab' should not move the focus around. Pseudo-code: ``` if (null !== this.selectedElement) { if (event.code === 'Escape' && !event.repeat) { this.restoreOrderAndDeselectSelectedElement(event); } if (event.code === 'Tab') { event.preventDefault(); event.currentTarget.focus(); } } ``` -
Willi Wehmeier uploaded patch set 6
V +104/11/24, 13:47 -
core-ci voted on patch set 6 V -1 04/11/24, 13:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55774
-
Willi Wehmeier commented on patch set 6 04/11/24, 13:59
_grid.scss:72ReplyChanged 😊widget-keyboard-control.ts:62ReplyI've added the possibility to cancel the move process with the escape key, thanks for the suggestion! 😊 Additionally key inputs are prevented now when there's a selected element and only esc, space and up/down arrow keys are allowed.widget-keyboard-control.ts:93ReplyI'm setting the focus manually now after repositioning of a widget and the screenreader output (voiceover on macos with chrome) is kinda random. Sometimes the live area content is read out with the success message, sometimes the screenreader describes the focused button. Currently I have no idea how to improve this, but otherwise I think it doesn't confuse the user and still improves the accessibility. -
Ayke Halder commented on patch set 6 04/11/24, 17:40
We should also focus the handle if the operation is unsuccessfull. E.g. these two use cases should result in the same focus state: Case A: 1. Focus drag-button by keyboard 2. Press [Space] -> element is selected. 3. Press [Space] again -> element is de-selected. -> Focus is on drag-button. Case B: 1. Focus drag-button by keyboard 2. Press [Space] -> element is selected 3. Press [Escape] -> element is de-sected -> Focus is **not** on drag-button. Focus should be on drag-button again.widget-keyboard-control.ts:114Maybe just save the current drag-button here before we set `this.selectedElement = null`: ```js const handle = (this.selectedElement.querySelector(this.dragButtonSelector) as HTMLElement); ```widget-keyboard-control.ts:119After save focus the handle: ```js handle.focus(); ```widget-keyboard-control.ts:189Also focus the handle if not successfull. Maybe move focus action into function `deselectSelectedElement` as we still have `this.selectedElement` over there. -
Ayke Halder commented on patch set 6 04/11/24, 17:54
Some code style improvements - please check if they make sense.widget-keyboard-control.ts:14CS - add: `import Grid from '@typo3/dashboard/grid';`widget-keyboard-control.ts:22CS - use Grid type: `private gridInstance: typeof Grid = null;`widget-keyboard-control.ts:37CS - use Grid type: `public initialize(muuriInstance: Muuri, grid: typeof Grid): void {`widget-keyboard-control.ts:98CS: I would use `event.currentTarget` instead of `event.target` as the event listener is bound to the drag-button anyway. See https://stackoverflow.com/a/10086501 > Events bubble by default. So the difference between the two is: > > * target is the element that triggered the event (e.g., the user clicked on) > * currentTarget is the element that the event listener is attached to.widget-keyboard-control.ts:186CS - ts-expect-error can be removed here. -
Willi Wehmeier uploaded patch set 7
V -104/12/24, 06:10 -
core-ci voted on patch set 7 V -1 04/12/24, 06:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55832
-
Willi Wehmeier commented on patch set 7 04/12/24, 06:33
Reply
The handle gets focused in both cases now (save/abort) 😎Reply
All done! Thanks for your input!_grid.scss:72ReplyDone! But we'll still have to get the pipeline lint task fixedwidget-keyboard-control.ts:14ReplyDone!widget-keyboard-control.ts:22ReplyThanks for the 'typeof Grid' code example. That was the missing part 😄widget-keyboard-control.ts:37Replydone!widget-keyboard-control.ts:98Replydone 😊widget-keyboard-control.ts:114Replydone!widget-keyboard-control.ts:119Replydone!widget-keyboard-control.ts:186Replydone!widget-keyboard-control.ts:189Replydone! -
Andreas Kienast uploaded patch set 8
V -104/12/24, 09:29 -
core-ci voted on patch set 8 V -1 04/12/24, 09:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55846
-
core-ci voted on patch set 8 V +1 04/12/24, 09:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55846
-
Andreas Kienast commented on patch set 8 CR -1 04/12/24, 10:07
widget-keyboard-control.ts:59This and all other methods can be private, right?widget-keyboard-control.ts:74Why is this called so late?widget-keyboard-control.ts:198I'd prefer to export the class only and create the instance in grid.ts instead, this might make `initialize()` obsolete.locallang.xlf:15I know it's missing in the whole file, but could you please add the `resname` attributes? -
Ayke Halder commented on patch set 8 04/12/24, 10:07
Looks pretty good now! Unfortunately I just realized what my suggestion to block the use of 'tab' and other keys while an element is selected really does. In Firefox the user cannot use internal browser functions at this moment anymore: * Zoom: [Ctrl] + [-] or [Ctrl] + [+] or [Ctrl] + [0] * Jump to url-bar: [Ctrl] + [L] Is this bad for UX or can we keep it like this? -
Willi Wehmeier rebased onto patch set 9
CR -1V +104/12/24, 10:25 -
Andreas Kienast commented on patch set 9 04/12/24, 10:29
Reply
IMO(!) browser shortcuts have precedence and should not get blocked. -
core-ci voted on patch set 9 V -1 04/12/24, 10:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55852
-
Willi Wehmeier uploaded patch set 10
V -104/12/24, 10:43 -
Willi Wehmeier commented on patch set 10 04/12/24, 10:47
Reply
I fixed that one with an early return when a key modifier is true in the KeyBoardEvent. It returns when the key that triggers the event is called together with ctrl/alt/option/cmd.widget-keyboard-control.ts:59Replychanged the methods to be private.widget-keyboard-control.ts:74ReplyI've adjusted the placing to call the prevent as early as possible 😊widget-keyboard-control.ts:198Replydone!locallang.xlf:15Replydone! -
core-ci voted on patch set 10 V -1 04/12/24, 10:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55853
-
Willi Wehmeier rebased onto patch set 11
V -104/12/24, 10:54 -
core-ci voted on patch set 11 V +1 04/12/24, 10:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55857
-
Willi Wehmeier uploaded patch set 12
V +104/12/24, 11:57 -
core-ci voted on patch set 12 V +1 04/12/24, 12:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55863
-
Ayke Halder commented on patch set 12 04/12/24, 12:39
widget-keyboard-control.ts:62This might additionally need: `event.preventDefault();` -
Willi Wehmeier commented on patch set 12 04/12/24, 12:45
widget-keyboard-control.ts:62ReplyThe question is: what should be prevented when the condition states, that only space and enter will be evaluated? -
Ayke Halder commented on patch set 12 04/12/24, 12:49
widget-keyboard-control.ts:59Maybe add an early return-condition here to have a clearly visible code-logic: ```js if (! this.selectedElement && ! (event.code === 'Space' || event.code === 'Enter')) { return; } event.preventDefault(); ``` Then we can remove the return-condition `if (! this.selectedElement)` and any `event.preventDefault()` in the code parts further down. -
Ayke Halder commented on patch set 12 04/12/24, 12:56
widget-keyboard-control.ts:59ReplyMight get simplified to ```js if (! (this.selectedElement || event.code === 'Space' || event.code === 'Enter')) { return; } event.preventDefault(); ``` -
Ayke Halder commented on patch set 12 04/12/24, 14:04
widget-keyboard-control.ts:62ReplyIn general I would go the approach: 1. Check that the input (`event.code`) should really be handled by this code. 2. Then for all handled inputs call `event.preventDefault()` and `event.stopPropagation()` - just in case. Note: `event.preventDefault()` also prevents browsers scrolling mechanism. ```js private handleKeyboardMoveEvent(event: KeyboardEvent): void { if (event.ctrlKey || event.altKey || event.metaKey) { return; } if (! event.code) { return; } if (! ['Space', 'Enter', 'Escape', 'ArrowDown', 'ArrowUp', 'Tab'].includes(event.code) ) { return; } if (! (this.selectedElement || ['Space', 'Enter'].includes(event.code))) { return; } event.preventDefault(); event.stopPropagation(); ``` Right now I found another edge case: The single keys PageUp/PageDown should still be working while an element is selected. Otherwise if there are too many elements you can't move the element to the right position by using ArrowDown/ArrowUp as you can't see the element anymore while moving it. -
Willi Wehmeier uploaded patch set 13
V +104/15/24, 08:22 -
Willi Wehmeier commented on patch set 13 04/15/24, 08:25
widget-keyboard-control.ts:62ReplyI've added PageUp, PageDown, Pos1/Hone and End to the keys, that are allowed to use while having an active widget to move. This should resolve your edge case 😊. -
core-ci voted on patch set 13 V +1 04/15/24, 08:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55983
-
Ayke Halder commented on patch set 13 04/15/24, 13:16
The refactoring to put the logics about keys into its own function `keyShouldBeHandled` is great! I would really appreciate to see not more keys than absolutely necessary blocked here. So better have a **white list** of all the keys that *really* are used by our code, than having the current **black list** of keys we like to pass to the browser. Such a black list must be extended every now and than. See the following single hotkey actions in Firefox: * F3: Find again / Opens search in page * F5: Reload * F6: Focus Address Bar / Move to Next Frame, Pop-Up * F7: Caret browsing * F11: Toggle Full Screen See https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly Other browser might have other important single key shortcuts. Accessbility tools like screenreaders or screen magnification might also add single key shortcuts. E.g. see https://www.freedomscientific.com/training/zoomtext/zoomtext-hotkeys/ > Layered Magnification Commands > > The following layered keys can be used to operate the Magnifier Commands. Press and release CAPS LOCK+SPACEBAR, followed by the keystrokes listed below to perform the action. > > | Command | Layered Keys | > | --- | --- | > | Magnifier Commands | CAPS LOCK+SPACEBAR, M | > | Enhance Colors On/Off | C | > | Enhance Cursor On/Off | R | > | Enhance Focus On/Off | F | > | Enhance Pointer On/Off | P | > | Enhance Smart Invert On/Off | I | > | Smoothing Mode | X | > | Toggle Zoom and 1x | ENTER | > | Zoom In | UP | > | Zoom Out | DOWN |widget-keyboard-control.ts:59ReplyDonewidget-keyboard-control.ts:62ReplyI would really appreciate to see not more keys than absolutely necessary blocked here. Better have a **white list** of all the keys that *really* are used by our code, than having the current **black list** of keys we like to pass to the browser. Such a black list must be extended every now and than. -
Willi Wehmeier uploaded patch set 14
V +104/15/24, 14:18 -
Willi Wehmeier commented on patch set 14 04/15/24, 14:19
Reply
Done!widget-keyboard-control.ts:62ReplyDone! -
core-ci voted on patch set 14 V +1 04/15/24, 14:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55995
-
Ayke Halder commented on patch set 14 04/15/24, 14:27
widget-keyboard-control.ts:62ReplyDonewidget-keyboard-control.ts:83UnresolvedThe old version had `ctrlKey`, `altKey` and `metaKey` handled, which is great. I would go for: ```js private static readonly ACTIVATION_KEYS string[] = ['Space', 'Enter']; private static readonly CONTROL_KEYS string[] = ['ArrowUp', 'ArrowDown', 'Space', 'Enter', 'Escape', 'Tab']; private keyShouldBeHandled(event: KeyboardEvent): boolean { if (!event.code || event.ctrlKey || event.altKey || event.metaKey) { return false; } if (WidgetKeyboardControl.ACTIVATION_KEYS.includes(event.code)) { return true; } if (!! this.selectedElement && WidgetKeyboardControl.CONTROL_KEYS.includes(event.code) ) { return true; } return false; } ``` -
Benjamin Kott commented on patch set 14 CR -1 04/16/24, 11:29
Unresolved
on it -
Benjamin Kott commented on patch set 14 04/17/24, 13:31
needs more work, postponed after 13.1 -
Benni Mack updated the commit message in patch set 15
CR -1V +110/18/24, 13:27 -
core-ci voted on patch set 15 V -1 10/18/24, 21:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67967
-
Benjamin Kott abandoned the change 02/24/25, 14:20
Abandoned in favor of a rewrite https://review.typo3.org/c/Packages/TYPO3.CMS/+/84097