Skip to content

Commit

Permalink
#4468 Fix selection box keyboard selection behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Sep 23, 2024
1 parent 608c73d commit 63120d0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ public void setRowData(final int start, final List<? extends I> values) {
protected void onBrowserEvent2(final Event event) {
if (event.getTypeInt() == Event.ONKEYDOWN) {
if (event.getKeyCode() == KeyCodes.KEY_UP) {
if (cellTable.getKeyboardSelectedRow() == 0) {
quickFilter.focus();
if (model.displayFilter()) {
if (cellTable.getKeyboardSelectedRow() == 0) {
quickFilter.focus();
}
}
} else if (event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
CloseEvent.fire(SelectionList.this);
Expand Down Expand Up @@ -151,7 +153,30 @@ public void setKeyboardSelectionPolicy(final KeyboardSelectionPolicy policy) {
}

public void focus() {
quickFilter.forceFocus();
if (model.displayFilter()) {
quickFilter.forceFocus();
} else {
final int selectionIndex = getSelectionIndex();
if (selectionIndex >= 0) {
cellTable.setKeyboardSelectedRow(selectionIndex, true);
} else if (cellTable.getKeyboardSelectedRow() >= 0) {
cellTable.setKeyboardSelectedRow(cellTable.getKeyboardSelectedRow(), true);
} else {
cellTable.setKeyboardSelectedRow(0, true);
}
}
}

private int getSelectionIndex() {
final List<I> items = cellTable.getVisibleItems();
if (items != null) {
for (int i = 0; i < items.size(); i++) {
if (cellTable.getSelectionModel().isSelected(items.get(i))) {
return i;
}
}
}
return -1;
}

@Override
Expand Down
24 changes: 24 additions & 0 deletions unreleased_changes/20240923_101350_833__4468.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
* Issue **#4468** : Fix selection box keyboard selection behavior when no quick filter is visible.


```sh
# ********************************************************************************
# Issue title: Some keybindings aren't working correctly
# Issue link: https://github.com/gchq/stroom/issues/4468
# ********************************************************************************

# ONLY the top line will be included as a change entry in the CHANGELOG.
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
# 'Fixed nasty bug'.
#
# Examples of acceptable entries are:
#
#
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
#
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
#
# * Fix bug with no associated GitHub issue.
```

0 comments on commit 63120d0

Please sign in to comment.