primeng icon indicating copy to clipboard operation
primeng copied to clipboard

MultiSelect or Dropdown as a filter triggers sort

Open preethi29 opened this issue 9 years ago • 20 comments

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

  1. Click on 'Colors' filter
  2. Select any color from the multiselect
  3. Colors column is sorted.
  4. Repeat the above procedure for 'Brand' column

What is the motivation / use case for changing the behavior? Sort is done on (click) event of . Instead it can be done '.ui-column-title' element. That way, filtering wont be affected.

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

preethi29 avatar Sep 06 '17 18:09 preethi29

Pull request- https://github.com/primefaces/primeng/pull/3861

preethi29 avatar Sep 06 '17 18:09 preethi29

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

preethi29 avatar Sep 07 '17 06:09 preethi29

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.

jonmarozick avatar Sep 13 '17 13:09 jonmarozick

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 .

preethi29 avatar Sep 14 '17 11:09 preethi29

I have observed this as well. I ended up adding event.stopPropagation() to the onMouseClick, onItemClick, and toggleAll functions.

pauly815 avatar Sep 15 '17 14:09 pauly815

I have added event.stopPropagation() as the interim fix but it creates other problems like stickiness of dropdown.

preethi29 avatar Sep 16 '17 11:09 preethi29

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 .

preethi29 avatar Sep 18 '17 07:09 preethi29

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.

pauly815 avatar Sep 19 '17 13:09 pauly815

Is there a temporary workaround for this? This is somewhat of a show-stopper.

JonKruger avatar Sep 28 '17 20:09 JonKruger

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.

JonKruger avatar Sep 28 '17 20:09 JonKruger

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.

cagataycivici avatar Oct 26 '17 08:10 cagataycivici

Also appendTo="body" helps these kinds of cases.

cagataycivici avatar Oct 26 '17 08:10 cagataycivici

@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?

preethi29 avatar Nov 07 '17 10:11 preethi29

DataTable is deprecated in favor new p-table and not maintained anymore.

p-table does not have this issue.

cagataycivici avatar Jan 31 '18 13:01 cagataycivici

@cagataycivici unfortunately p-table still seems to have this issue: http://plnkr.co/edit/D0eue9uk0o58kWLDBIGO?p=preview

ericsvendsen avatar Feb 21 '18 05:02 ericsvendsen

I have this same issue too. Seems like you can't do filter and sort on same column.

SeanLeitzinger avatar Feb 23 '18 18:02 SeanLeitzinger

In TurboTable, you need to move the filters to their own row.

https://www.primefaces.org/primeng/#/table/filter

cagataycivici avatar Mar 02 '18 07:03 cagataycivici

Yeah, that's what I ended up doing. Seems to work ok now.

SeanLeitzinger avatar Mar 02 '18 15:03 SeanLeitzinger

Managed to solve by disabling "Propogation" events:

  1. Wrap the p-multiSelect with a div
  2. 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>

yonatanayalon avatar Mar 12 '18 15:03 yonatanayalon

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>

buichlj avatar Jul 25 '18 20:07 buichlj