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

Sorting fails when a one or more sorted columns is hidden #1015

Closed
5 tasks done
LordGalahad opened this issue Apr 22, 2024 · 14 comments · Fixed by #1016
Closed
5 tasks done

Sorting fails when a one or more sorted columns is hidden #1015

LordGalahad opened this issue Apr 22, 2024 · 14 comments · Fixed by #1016

Comments

@LordGalahad
Copy link

Describe the bug

I'm not sure if this is intended behavior though.

When I have multiColumnSort enabled, and I have multiple columns currently selected like this:

image

And then try to hide one of the sorted columns (like GBP), so it ends up looking like this:

image

And then I try to click on another column (like vNoise), I get this error:

image

image

We had no problems with the old slickgrid. But since this is new implementation, it may seem to be limitation?

Reproduction

  1. Set multiColumnSort to true
  2. Select two or more columns to be sorted
  3. Hide one of the sorted columns
  4. Click on a different column for sorting

Which Framework are you using?

Other

Environment Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 3.39 GB / 15.73 GB
  Binaries:
    Node: 18.18.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.6 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (124.0.2478.51)
    Internet Explorer: 11.0.19041.3636
  Slickgrid: 5.8.0

Validations

@ghiscoding
Copy link
Collaborator

ghiscoding commented Apr 22, 2024

There's not enough info/details to help you, just doing print screens of UI and code is not helpful enough for us to understand the problem. I'm not even sure if you're asking about the new hidden property on the column definition? If that is the case then @6pac could help since I'm not using that option on my side. You should provide full repro or else we cannot help

@LordGalahad
Copy link
Author

I actually tried it on one of the samples - https://6pac.github.io/SlickGrid/examples/example-column-hidden.html

I tried setting options.multiColumnSort to true. Then I select two columns to be sorted. Then I hide one of the two sorted columns. Then I select a different column to sort. Then I get the exception error

Here is a loom video: https://www.loom.com/share/ab26e2aa6e674a2d93cc0428da2a6b2d

@6pac
Copy link
Owner

6pac commented Apr 23, 2024

@LordGalahad thanks, too busy today, but I'll have a look tomorrow morning (GMT+09:30). There was a lot of debate around the changes, I'll have to go back and look at exactly how we did it.

@6pac
Copy link
Owner

6pac commented Apr 24, 2024

Sorry, I'm trying to repro but I can't get the error to happen in the examples with a .js source. I notice you are referencing a .ts source directly in your examples file. How are you doing that?
This might seem a silly question, but this getting dangerously close to being only @ghiscoding 's project. I don't use TS or any of the tooling that the current repo uses. At the moment they are a significant barrier to me being able to diagnose or patch anything. I do all my diagnosis and coding in js and then have to back-patch to ts and get the dist files to flow through.

@LordGalahad
Copy link
Author

But I simplified it by just using the sample provided by the wiki here (I'm not using my own code anymore)
https://6pac.github.io/SlickGrid/examples/example-column-hidden.html

What I just did was set a breakpoint in the sample and set options.multiColumnSort to TRUE
image

Then, shift + click each column to sort
image

Then hide one of the sorted columns (I hid % Complete by right clicking on the header and deselecting it)
image

Then shift +click on another column to sort it as well. (like Start Date)

When this happens, there will an exception occurring.

If you use ordinary click, you will encounter no problems

@6pac
Copy link
Owner

6pac commented Apr 25, 2024

@LordGalahad thanks, I could repro. I was missing the final shift-click.

@ghiscoding this is actually nothing to do with the hidden property - it's happening because the column menu is not using the hidden property but is removing the column from the columns array, while it still is listed in the column sort array. This must have been a pre-existing bug. I have created a PR to fix. (note - bugs like this are exactly why we needed the hidden property - keeping multiple column lists in sync across possibly multiple components is a nightmare)

Both of you: this does raise another usage question. If we are ordering by a column and it is then hidden, should it be removed from the sort list? I can see use cases either way. Should we create an option, say removeHiddenColsFromSort, defaulting to false so as to be non breaking? This would require additional changes, which I can do.

@ghiscoding
Copy link
Collaborator

@6pac that bug was also reported in the past when you introduced the hidden feature, see #546
I didn't look at the code, I just remembered that it was a similar bug

@6pac
Copy link
Owner

6pac commented Apr 25, 2024

@ghiscoding ah yes, good catch. Any opinion on the usage question?

@ghiscoding
Copy link
Collaborator

Any opinion on the usage question?

I'm not sure what you mean, could you elaborate?

@6pac
Copy link
Owner

6pac commented Apr 25, 2024

Both of you: this does raise another usage question. If we are ordering by a column and it is then hidden, should it be removed from the sort list? I can see use cases either way. Should we create an option, say removeHiddenColsFromSort, defaulting to false so as to be non breaking? This would require additional changes, which I can do.

This is referring to the use of the hidden flag, where the column is still in the list

@ghiscoding
Copy link
Collaborator

I was ok with your PR approach, I would find that weird that we would still sort by a column that is not visible to the user since it could bring too much confusion (I like the approach of "What you see is what you get")

@6pac
Copy link
Owner

6pac commented Apr 25, 2024

OK, no worries, but in that case I should also filter for columns that exist but are hidden. Will tweak it some more.

Thanks for the hint on debugging too.

ghiscoding pushed a commit that referenced this issue May 7, 2024
…ts (#1016)

* fix: Tweak setupColumnSort() to fix exception when a no longer existing column is in the sort list. Fixes #1015

* fix: also skip hidden columns in sort
@ghiscoding
Copy link
Collaborator

should be fixed in v5.9.2

@LordGalahad
Copy link
Author

Yup it is fixed. Thanks

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

Successfully merging a pull request may close this issue.

3 participants