Skip to content

Commit

Permalink
#4684 Fix focus issue for table quick filter
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Jan 31, 2025
1 parent 9670c92 commit 8b4a18f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2637,4 +2637,16 @@ private void updateColumnWidthImpl(Column<T, ?> column, String width) {
}
}
}

/**
* To fix issue gh-4684 we stop tables from taking focus if the user is clicking an item in the header.
* This allows the header controls (filer text boxes) to take focus themselves.
*/
@Override
boolean allowFocus(final Element element) {
if (getTableHeadElement().isOrHasChild(element)) {
return false;
}
return super.allowFocus(element);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void resetFocus() {
CellBasedWidgetImpl.get().resetFocus(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
if (!hasData.resetFocusOnCell()) {
if (!hasData.resetFocusOnCell() && wasFocused) {
Element elem = hasData.getKeyboardSelectedElement();
if (elem != null) {
FocusUtil.focusRow(elem);
Expand Down Expand Up @@ -777,21 +777,29 @@ private void rememberFocus(Event event) {
final Element target = Element.as(eventTarget);
if (BrowserEvents.FOCUS.equals(eventType)) {
// Remember the focus state.
isFocused = true;
isFocused = allowFocus(target);
} else if (BrowserEvents.BLUR.equals(eventType)) {
// Remember the blur state.
isFocused = false;
} else if (BrowserEvents.KEYDOWN.equals(eventType)) {
// A key event indicates that we already have focus.
isFocused = true;
isFocused = allowFocus(target);
} else if (BrowserEvents.MOUSEDOWN.equals(eventType)
&& CellBasedWidgetImpl.get().isFocusable(Element.as(target))) {
// If a natively focusable element was just clicked, then we must have
// focus.
isFocused = true;
isFocused = allowFocus(target);
}
}

/**
* Provide a method so that subclasses can choose if this widget is allowed to obtain focus.
* This was introduced to fix issue gh-4684
*/
boolean allowFocus(Element element) {
return true;
}

/**
* Redraw the widget using the existing data.
*/
Expand Down
24 changes: 24 additions & 0 deletions unreleased_changes/20250131_152646_253__4684.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
* Issue **#4684** : Fix focus issue for table quick filter.


```sh
# ********************************************************************************
# Issue title: Column Filter loses focus during table update
# Issue link: https://github.com/gchq/stroom/issues/4684
# ********************************************************************************

# 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 8b4a18f

Please sign in to comment.