diff --git a/vaadin-simple-grid-filter/src/main/java/software/xdev/vaadin/FilterComponent.java b/vaadin-simple-grid-filter/src/main/java/software/xdev/vaadin/FilterComponent.java index ff0d08c..58a46d4 100644 --- a/vaadin-simple-grid-filter/src/main/java/software/xdev/vaadin/FilterComponent.java +++ b/vaadin-simple-grid-filter/src/main/java/software/xdev/vaadin/FilterComponent.java @@ -369,19 +369,24 @@ private void onAcceptFilter() final boolean deletable; final boolean editable; - // Check if it's an initial condition - if(this.editingBadgeId != null && !this.editingBadgeId.equals(NO_BADGE_ID_STRING)) + if(this.deletingBadgeEnabled != null && this.editingBadgeEnabled != null) { deletable = this.deletingBadgeEnabled; editable = this.editingBadgeEnabled; - // Get customization rating from initial condition - customizationDegree = this.initialChipBadges - .stream() - .filter(e -> e.getBadgeId().equals(this.editingBadgeId)) - .toList() - .get(0) - .getCustomizationRating(); + this.deletingBadgeEnabled = null; + this.editingBadgeEnabled = null; + + if(this.editingBadgeId != null) + { + // Get customization rating from initial condition + customizationDegree = this.initialChipBadges + .stream() + .filter(e -> e.getBadgeId().equals(this.editingBadgeId)) + .toList() + .get(0) + .getCustomizationRating(); + } } else { @@ -461,17 +466,15 @@ private void onAcceptFilter() // Make the cancel button invisible this.btnCancelFilter.setVisible(false); + // Needed to save state of the condition if it was editable/deletable before editing + this.editingBadgeEnabled = badge.isBtnEditEnabled(); + this.deletingBadgeEnabled = badge.isBtnDeleteEnabled(); + + // Just activated when the url parameters are enabled // Set the customization rating for the filter select and condition select this.setUsedCustomizationDegreeForComponents(customizationDegree); - // Just activated when the url parameters are activated - if(!this.identifier.isBlank()) - { - this.editingBadgeId = badge.getBadgeId(); - // Needed for the acceptFilterBtn - this.editingBadgeEnabled = badge.isBtnEditEnabled(); - this.deletingBadgeEnabled = badge.isBtnDeleteEnabled(); - } + this.editingBadgeId = badge.getBadgeId(); // Remove filter, update grid this.removeChipBadgeCondition(badge);