Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4684 Fix focus issue for table quick filter #4751

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
```