MultiSelect or Dropdown as a filter triggers sort
I'm submitting a ... (check one with "x")
[ x ] bug report => Search github for a similar issue or PR before submitting
Plunkr Case (Bug Reports) Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.
http://plnkr.co/edit/3G1G8JGACKpHTf37gGYT?p=preview
Current behavior when p-multiselect or p-dropdown is used as datatable filter, clicking anywhere in the multiselect triggers sort
Expected behavior Click on multiselect or dropdown when used as filter template, should not trigger sort of the datatable column. Sorting can be limited just to column title instead of whole column space.
Minimal reproduction of the problem with instructions http://plnkr.co/edit/3G1G8JGACKpHTf37gGYT?p=preview
- Click on 'Colors' filter
- Select any color from the multiselect
- Colors column is sorted.
- Repeat the above procedure for 'Brand' column
What is the motivation / use case for changing the behavior? Sort is done on (click) event of
Please tell us about your environment:
- Angular version: 4.0.0
- PrimeNG version: 4.1.2
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] All
Pull request- https://github.com/primefaces/primeng/pull/3861
Instead of limiting the click event to .ui-column-title, we can also stop bubbling up the event when we click on multiselect item. Pull request raised for the same: https://github.com/primefaces/primeng/pull/3866
We've added some custom padding in the p-multiselect and now that exposes a bit more area where clicking on the multiselect casues a sort.
Ideally the multiselect need not propagate its event outside its scope.
On 13-Sep-2017 7:26 PM, "Jon Marozick" [email protected] wrote:
We've added some custom padding in the p-multiselect and now that exposes a bit more area where clicking on the multiselect casues a sort.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/primefaces/primeng/issues/3859#issuecomment-329175649, or mute the thread https://github.com/notifications/unsubscribe-auth/AE3Z3Xcw4zm8E5iV8ttuGYIBK4f2x2ILks5sh98EgaJpZM4POygU .
I have observed this as well. I ended up adding event.stopPropagation() to the onMouseClick, onItemClick, and toggleAll functions.
I have added event.stopPropagation() as the interim fix but it creates other problems like stickiness of dropdown.
Any updates on this issue?
On 15-Sep-2017 8:19 PM, "Paul Kim" [email protected] wrote:
I have observed this as well. I ended up adding event.stopPropagation() to the onMouseClick, onItemClick, and toggleAll functions.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/primefaces/primeng/issues/3859#issuecomment-329804696, or mute the thread https://github.com/notifications/unsubscribe-auth/AE3Z3XSFg80aiFxLucdRWGDVqcd3FbPMks5sio6MgaJpZM4POygU .
I actually like the sticky dropdown. Double click on something else (like the table data) and they all close. I also have my load function close all multiselects if they're open.
Is there a temporary workaround for this? This is somewhat of a show-stopper.
Answering my own question... added this attribute to my <p-multiSelect> fixed it for me...
(click)="$event.stopPropagation();"
... but now after I click the "x" button the multi-select dropdown, I can't get the dropdown to pull down anymore.
Can't replicate with 4.3.0, please try with it when it comes out and we'll discuss again. Create a new issue please if that is the case.
Also appendTo="body" helps these kinds of cases.
@cagataycivici I see the issue in 4.3.0 as well. I see that my PR #3866 has been merged to master but not released in 4.3.0. Can we expect this in next release?
DataTable is deprecated in favor new p-table and not maintained anymore.
p-table does not have this issue.
@cagataycivici unfortunately p-table still seems to have this issue: http://plnkr.co/edit/D0eue9uk0o58kWLDBIGO?p=preview
I have this same issue too. Seems like you can't do filter and sort on same column.
In TurboTable, you need to move the filters to their own row.
https://www.primefaces.org/primeng/#/table/filter
Yeah, that's what I ended up doing. Seems to work ok now.
Managed to solve by disabling "Propogation" events:
- Wrap the p-multiSelect with a div
- Add click event to div, which stops event bubbling (propagation)
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of cols">
{{col.header}}
<div (click)="$event.stopPropagation()" class="filter-icon">
<i class="fa fa-filter" aria-hidden="true"></i>
<p-multiSelect... />
</div>
</th>
</tr>
</ng-template>
For anybody still having this issue and cannot upgrade past 4.3 the workaround I found was binding the sortable attribute on the table column to a boolean variable. Then in the (onPanelShow)/(onPanelHide) of the p-multiselect set that variable to false/true respectively. Example:
<p-column [sortable]="sortVariable" [filter]="true"... >
< ng-template pTemplate="filter" let-col>
<p-multiSelect (onPanelShow)="sortVariable = false;" (onPanelHide)="sortVariable = true"... >
</p-multiselect>
</ ng-template>
</p-column>