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

PoC sorting by binary index and municipality #632

Draft
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

belanglos
Copy link
Contributor

@belanglos belanglos commented Jun 4, 2024

A proof of concept for multisort if the index column contains binary data (as far as I've seen this is the case in klimatplanerna and upphandlingarna).

It seems to work well for klimatplanerna, but it does not work for upphandlingarna and I cannot see why.

Copy link

vercel bot commented Jun 4, 2024

@belanglos is attempting to deploy a commit to the Klimatbyrån Team on Vercel.

A member of the Team first needs to authorize it.

@LudwikJaniuk
Copy link
Contributor

I saw this while running:
image

@LudwikJaniuk
Copy link
Contributor

I wonder if, as an alternative to the current custom sort solution, TanStack's multisorting feature could be useful?

https://tanstack.com/table/v8/docs/guide/sorting/#multi-sorting

Copy link

vercel bot commented Jun 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
klimatkollen ❌ Failed (Inspect) Jun 5, 2024 7:09am

@belanglos
Copy link
Contributor Author

Thanks for having a look @LudwikJaniuk !
I've also read about the multisorting, but as far as I understand it, it allows the user to manually sort by multiple columns by holding the shift key and clicking on the additional column. Is this enough to satisfy the requirement?

For programmatically invoking the multi-sort, i.e. having the table sort by index, name (e.g. "Har plan", "Kommun"), i understand it as if altering the sorting state is the way to go. I got the idea from one of the first paragraphs where it says Since the sorting state is an array, it is possible to sort by multiple columns at once.

However, I've played around with multi-sort a little bit now and the interesting thing is that if I sort by Har plan and then shift-click on Kommun while logging the sorting state the resulting sorting state is the same as with the intercepted solution. BUT it still does not work for the Upphandlingar-datatype, which leads me to believe that something is off for some reason that we don't know yet.

@belanglos
Copy link
Contributor Author

Added another branch with user-controlled multi-sorting (shift-click): https://github.com/belanglos/klimatkollen/tree/351-multi-sorting-poc

@LudwikJaniuk
Copy link
Contributor

Shift click actually works by-default on the site as it is live: klimatkollen.se

And a difference between "Upphandlingarna" and "Klimatplanerna" can be observed there too. Maybe that is the first place to start - to figure out the difference?

allows the user to manually sort by multiple columns by holding the shift key and clicking on the additional column. Is this enough to satisfy the requirement?

IMO no, because no one will guess that (and no shift on mobile). When sorting on "Ja/Nej", it makes no sense to have a "random" sort on the rest.

@belanglos
Copy link
Contributor Author

Shift click actually works by-default on the site as it is live: klimatkollen.se

I totally missed that this was the default-behaviour in Tanstack/table. Thanks for pointing that out!

IMO no, because no one will guess that (and no shift on mobile). When sorting on "Ja/Nej", it makes no sense to have a "random" sort on the rest.

I totally agree with you!

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 this pull request may close these issues.

2 participants