diff --git a/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractCellTable.java b/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractCellTable.java index c2bdb4a4ef..1a4982e46b 100644 --- a/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractCellTable.java +++ b/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractCellTable.java @@ -2637,4 +2637,16 @@ private void updateColumnWidthImpl(Column 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); + } } diff --git a/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractHasData.java b/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractHasData.java index 7396a2311e..abf92de157 100644 --- a/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractHasData.java +++ b/stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractHasData.java @@ -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); @@ -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. */ diff --git a/unreleased_changes/20250131_152646_253__4684.md b/unreleased_changes/20250131_152646_253__4684.md new file mode 100644 index 0000000000..b0a0b028f3 --- /dev/null +++ b/unreleased_changes/20250131_152646_253__4684.md @@ -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. +```