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

Table: Incorrect behavior when a column is both sortable and filterable, and user clicks on a certain part of the filter icon #13361

Closed
WesleySSmith opened this issue Jul 21, 2023 · 2 comments · Fixed by #13392
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@WesleySSmith
Copy link

Describe the bug

If a table has a column that's both filterable and sortable, and if the user clicks on the part of the filter icon's SVG path, then the filter dialog will appear (as expected), but also the column will change the sort (which is a bug).

The bug is in the isFilterElement function here:

return DomHandler.hasClass(element, 'pi-filter-icon') || DomHandler.hasClass(element, 'p-column-filter-menu-button');

So, the isFilterElement function will return true if the target of the click event has the 'pi-filter-icon' class. And this will be true if the click is over the svg (but not on a particular path). However, if the user clicks on the path itself, then the target element will be the path itself, which doesn't have the 'pi-filter-icon' class, and so the isFilterElement function will (incorrectly) return false.

I think a better approach would be to remove the isFilterElement approach completely and instead call event.stopPropagation() here:

this.overlayVisible = !this.overlayVisible;

Environment

Can be seen on the PrimeNg sample pages here:
https://primeng.org/table#customers

Reproducer

No response

Angular version

16

PrimeNG version

16.0.2

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

N/A

Browser(s)

No response

Steps to reproduce the behavior

Go to https://primeng.org/table#customers
Note that the example table has both sorting and filtering
Click in the center of the filter icon (the part that has the background color)
Note that the filter dialog appears or disappears, but the sort doesn't change. This is correct.
Click the on the edge of the filter icon (the part that's dark gray). This is a thin line, so it may help to zoom the window.
Note that the filter dialog appears or disappears, and also, the sort changes. This is incorrect

Expected behavior

No matter where you click on the filter icon, the sort doesn't change.

@WesleySSmith WesleySSmith added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 21, 2023
@senasowseelya
Copy link

senasowseelya commented Jul 28, 2023

@WesleySSmith, Thanks for sugesting the approach. It has been implemented in the below PR.

#13392

@cetincakiroglu

@gucal gucal added this to the 16.2.1 milestone Aug 28, 2023
@gucal gucal added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 28, 2023
rosenthalj added a commit to rosenthalj/primeng that referenced this issue Sep 26, 2023
merge pull request primefaces#13392 fixed issue primefaces#13361 but caused filters not to automatically close when clicking different filter buttons.

This change properly  fixes issue primefaces#13361 and as a result fixes the bug that was induced by the original attempted fix.

Instead of stopping the click event propagation,   the isFilterElement method is improved by calling a new  isFilterElementIconOrButton method
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 27, 2023
@cetincakiroglu cetincakiroglu modified the milestones: 16.3.0, 16.4.1 Sep 27, 2023
@cetincakiroglu cetincakiroglu removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 27, 2023
cetincakiroglu added a commit that referenced this issue Sep 27, 2023
@cetincakiroglu
Copy link
Contributor

Fixed in #13754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants