Skip to content

Commit

Permalink
filter widgets are navigable using (shift+)tab and left and `righ…
Browse files Browse the repository at this point in the history
…t` arrow keys [feenkcom/gtoolkit#3983]
  • Loading branch information
JurajKubelka committed Sep 26, 2024
1 parent 43d6249 commit bc1e129
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/GToolkit-Coder-UI/GtFilterItemsElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,39 @@ GtFilterItemsElement >> addElementForFilterViewModel: aFilterViewModel [
constraintsDo: [ :c |
c flow vertical alignCenter.
c flow horizontal alignLeft ].

self addNavigationShortcutsTo: anElement.

self addChild: anElement
]

{ #category : #'private - updating' }
GtFilterItemsElement >> addNavigationShortcutsTo: anElement [
anElement
addShortcut: (BlShortcutWithAction new
name: 'Move to next filter';
description: 'Moves to the next form item. If none is found, we cycle back to the first.';
combination: (BlKeyCombination tab or: BlKeyCombination arrowRight);
overrideChildren: false;
action: [ :anEvent |
BlFocusFinder new
direction: BlFocusSearchDirectionForward new;
root: self;
referenceElement: anEvent currentTarget;
nextFocusDo: #requestFocus ifNone: [ ] ]);
addShortcut: (BlShortcutWithAction new
name: 'Move to previous form item';
description: 'Moves to the previous form item. If none is found, we cycle back to the last.';
combination: (BlKeyCombination shiftTab or: BlKeyCombination arrowLeft);
overrideChildren: false;
action: [ :anEvent |
BlFocusFinder new
direction: BlFocusSearchDirectionBackward new;
root: self;
referenceElement: anEvent currentTarget;
nextFocusDo: #requestFocus ifNone: [ ] ]).
]

{ #category : #'private - updating' }
GtFilterItemsElement >> addNewFilterElement [
self addChild: self newAddFilterButton as: #add
Expand Down Expand Up @@ -98,6 +128,8 @@ GtFilterItemsElement >> newAddFilterButton [
content: [ self createDropdownContent ]);
margin: (BlInsets left: 2);
constraintsDo: [ :c | c flow vertical alignCenter ];
beFocusable;
in: [ :anElement | self addNavigationShortcutsTo: anElement ];
addShortcut:
(BlShortcutWithAction new
combination: BlKeyCombination enter;
Expand Down
5 changes: 4 additions & 1 deletion src/GToolkit-Coder-UI/GtFilterTextSettingsElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ GtFilterTextSettingsElement >> initializeEditorElement [
combination: BlKeyCombination enter;
action: [ :anEvent |
self onTextEditorModificationAccepted: anEvent ]);
when: BlFocusInEvent do: [ :anEvent |
anEvent currentTarget selecter all select ];
when: BlFocusOutEvent do: [ :anEvent |
anEvent currentTarget deselecter all deselect.
anEvent isDueToRemoval ifFalse: [
self onTextEditorModificationAccepted: anEvent ] ].
self onTextEditorModificationAccepted: anEvent ] ]
]

{ #category : #'api - filter view model' }
Expand Down

0 comments on commit bc1e129

Please sign in to comment.