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

Columns are sorted when clicking header filters #3521

Open
mordonez-me opened this issue Jun 6, 2024 · 3 comments
Open

Columns are sorted when clicking header filters #3521

mordonez-me opened this issue Jun 6, 2024 · 3 comments
Labels

Comments

@mordonez-me
Copy link

Describe the bug

To Reproduce

  1. Create a header with a filter like the the [Header filters](example https://adazzle.github.io/react-data-grid/#/header-filters)
  2. Enable sorting like in the [Columns reordering[(example https://adazzle.github.io/react-data-grid/#/columns-reordering)

Expected behavior

Not sort the column

Environment

  • react-data-grid version: ^7.0.0-beta.44
  • react/react-dom version: ^18.2.0

Additional context

The problem comes from this line

onClick={onClick}

onClick is on top of everything so anything you put inside the header div will be activated as soon as you click the cell, even the filter which is inside the header renderer

Video:

Monosnap.screencast.2024-06-06.08-43-19.mp4
@mordonez-me mordonez-me added the Bug label Jun 6, 2024
@balaji-sivasakthi
Copy link
Contributor

balaji-sivasakthi commented Sep 4, 2024

Share Codepen link, It would be more helpful

@amanmahajan7
Copy link
Contributor

Can you create a reproducible example?

@leeoniya
Copy link

leeoniya commented Nov 28, 2024

@amanmahajan7 @nstepien we're having a similar issue/need.

we don't want the entire header cell to be clickable for sorting purposes, since there are additional buttons/controls in there for other things, such as pulling up a filter popup. it would be very useful to delegate what should trigger sorting to the user-supplied children of HeaderCell via a render prop or callback arg like doSort, or smth.

currently i think the only way to do this is by hackily binding listeners in the children with stopPropagation to prevent the built-in sort behavior (both click and keypress).

some flexibility here would be much appreciated.

i see there are some related issues with filters in header cells, so feels like it's not such an edge case:

if this is already possible, please add a demo that shows how you recommend adding interactive elements to the header while also avoiding sorting.

thank you(s)!

example:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants