From d063735abe49c9fe6124b8134633972d2887f0bb Mon Sep 17 00:00:00 2001 From: Dmitry Kremnev Date: Mon, 13 Jan 2025 17:11:29 +0400 Subject: [PATCH] Filter with default configuration is not applied if the link was opened in a new browser tab jmix-framework/jmix#4018 (cherry picked from commit 391d077ba9f790ed4999ef5b929e045a57b13792) --- .../component/filter/SingleFilterComponentBase.java | 5 ++++- .../flowui/component/genericfilter/GenericFilter.java | 9 ++++----- .../component/genericfilter/GenericFilterSupport.java | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/filter/SingleFilterComponentBase.java b/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/filter/SingleFilterComponentBase.java index d653a73770..d8a0adba0b 100644 --- a/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/filter/SingleFilterComponentBase.java +++ b/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/filter/SingleFilterComponentBase.java @@ -107,7 +107,10 @@ protected void initComponent() { protected void onFilterValueChanged(ComponentValueChangeEvent, V> event) { updateQueryCondition(event.getValue()); - apply(); + + if (event.isFromClient()) { + apply(); + } } protected HorizontalLayout createRootComponent() { diff --git a/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilter.java b/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilter.java index e983b6a345..0910e726e0 100644 --- a/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilter.java +++ b/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilter.java @@ -582,14 +582,13 @@ public void setCurrentConfiguration(Configuration currentConfiguration) { protected void setCurrentConfigurationInternal(Configuration currentConfiguration, boolean fromClient) { if (configurations.contains(currentConfiguration) || getEmptyConfiguration().equals(currentConfiguration)) { + if (this.currentConfiguration != currentConfiguration) { + clearValues(); + } Configuration previousConfiguration = this.currentConfiguration; this.currentConfiguration = currentConfiguration; - if (previousConfiguration != currentConfiguration) { - clearValues(); - } - refreshCurrentConfigurationLayout(); updateSelectConfigurationDropdown(); @@ -977,7 +976,7 @@ protected void clearValues() { return; } - for (FilterComponent component : getCurrentConfiguration().getRootLogicalFilterComponent().getFilterComponents()) { + for (FilterComponent component : rootLogicalFilterComponent.getFilterComponents()) { if (component instanceof SingleFilterComponentBase singleFilterComponent) { singleFilterComponent.setValue(getCurrentConfiguration() .getFilterComponentDefaultValue(singleFilterComponent.getParameterName())); diff --git a/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilterSupport.java b/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilterSupport.java index f19eacbd6d..309acc5702 100644 --- a/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilterSupport.java +++ b/jmix-flowui/flowui/src/main/java/io/jmix/flowui/component/genericfilter/GenericFilterSupport.java @@ -98,6 +98,7 @@ public Map initConfigurationValuesMap(Configuration configuratio SingleFilterComponentBase singleFilterComponent = ((SingleFilterComponentBase) filterComponent); String parameterName = singleFilterComponent.getParameterName(); valuesMap.put(parameterName, singleFilterComponent.getValue()); + singleFilterComponent.setValue(configuration.getFilterComponentDefaultValue(parameterName)); } }