Skip to content

Conversation

@lcarrasco-xdev
Copy link
Member

Steps to reproduce:

  1. Add two filter components which should filter the same grid to the ui.
  2. Add a custom condition to the first filter component.
  3. Add a custom condition to the second filter component.
  4. The second condition overwrites the first one.

Expected behavior: At step 4 the second condition should not overwrite the first one. The second condition should be combined with the first condition.

… event is now fired, telling other filter components that they should add their filter back to the grid.
@sonarqubecloud
Copy link

@AB-xdev AB-xdev self-assigned this Oct 18, 2024
Copy link
Member

@AB-xdev AB-xdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general problems from my side:

  1. I'm having some serious doubts if this change is needed in the first place. I think the use-case of needing multiple "filter components" for one Grid is extremely unlikely.
  2. The current solution is not bound to the Grid that should be filter but instead to the UI, meaning that all "filter components" on the same UI are updated, which can result in unexpected behavior.
  3. Self-registering an listener for communication between different components is not a good practice and breaks encapsulation. This will result in "works with magic"-behavior observed by users of the component.

this.registration.remove();
}

private static class FilterComponentResetGridFilterEvent extends ComponentEvent<FilterComponent>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type is missing, see sonar for more details

this.removeQueryParameter(chip);
}

private void updateGridFilter()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method is called updateGridFilter but it just removes filters and throws a FilterComponentResetGridFilterEvent.

Should likely be called resetGridFilters or?

Comment on lines +1536 to +1550
final List<Predicate<T>> predicates = new ArrayList<>();

for(final ChipBadge<FilterCondition<T, ?>> chipBadge : chipBadges)
{
final FilterCondition<T, ?> item1 = chipBadge.getItem();
final String inputValue = item1.getInputValue();

predicates.add(
item1.getSelectedCondition().compare(
item1.getItem().getValueProvider(),
inputValue)
);
}

return predicates.stream().map(p -> p.test(item)).reduce(Boolean::logicalAnd).orElseThrow();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can likely be written with Streaming API

}

// Needed for interacting with other filter components on the same ui
private Registration registration;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be protected so that it can be overriden

@JohannesRabauer
Copy link
Member

I think @AB-xdev has good points as to why we should not merge this change: #7 (review)
That's why i'm closing this PR for now.

@JohannesRabauer JohannesRabauer deleted the multiple-fcs-overwrite-each-other-conditions-fix branch December 18, 2024 10:43
xdev-gh-bot pushed a commit that referenced this pull request Sep 1, 2025
…action-digest

Update lycheeverse/lychee-action digest to 885c65f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants