Table: Incorrect behavior when a column is both sortable and filterable, and user clicks on a certain part of the filter icon #13361
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
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:
primeng/src/app/components/table/table.ts
Line 3350 in ea0f869
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:
primeng/src/app/components/table/table.ts
Line 5104 in ea0f869
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.
The text was updated successfully, but these errors were encountered: