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

fix(table viz): correctly sort by multiple columns in a table #19920

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

stevetracvc
Copy link
Contributor

@stevetracvc stevetracvc commented May 2, 2022

Recent commit to sort alphanumeric columns via case insensitive
comparison broke the multi-column sort option. React-table only sorts
by the second (or third...) column if the first column matches.
Since the alphanumeric sort only returned -1 or 1, it never would move
to the subsequent columns when the earlier column values matched.

SUMMARY

prior commit only returned -1 or +1, resulting in a value of -1 when two rows had the same value for a given column.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Unsorted:
table_unsorted

Sorted by Platform:
table_sortby-platform

Sorted by Platform AND Global Sales (broken):
table_sortby-platform-globalsales

Sorted by Platform and Global Sales (fixed):
table_sortby-platform-globalsales-correct

TESTING INSTRUCTIONS

I added a new test to check for properly sorting by multiple columns (using react-table's

ADDITIONAL INFORMATION

  • Has associated issue: Table Viz - Sorting by multiple columns no longer works #19919
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Recent commit to sort alphanumeric columns via case insensitive
comparison broke the multi-column sort option. React-table only sorts
by the second (or third...) column if the first column matches.
Since the alphanumeric sort only returned -1 or 1, it never would move
to the subsequent columns when the earlier column values matched.
@stevetracvc
Copy link
Contributor Author

For reference, there's something on the react-table repo about this too

TanStack/table#3512

@codecov
Copy link

codecov bot commented May 2, 2022

Codecov Report

Merging #19920 (abbae32) into master (aff10a7) will not change coverage.
The diff coverage is 100.00%.

❗ Current head abbae32 differs from pull request most recent head 8cce51f. Consider uploading reports for the commit 8cce51f to get more accurate results

@@           Coverage Diff           @@
##           master   #19920   +/-   ##
=======================================
  Coverage   66.52%   66.52%           
=======================================
  Files        1714     1714           
  Lines       65052    65052           
  Branches     6722     6721    -1     
=======================================
  Hits        43279    43279           
  Misses      20061    20061           
  Partials     1712     1712           
Flag Coverage Δ
javascript 51.25% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...DataTable/utils/sortAlphanumericCaseInsensitive.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aff10a7...8cce51f. Read the comment docs.

@stephenLYZ stephenLYZ requested a review from kgabryje May 18, 2022 16:11
@stevetracvc
Copy link
Contributor Author

@stephenLYZ @kgabryje anything else you think this needs?

Copy link
Member

@stephenLYZ stephenLYZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Work! Looks good to me!

@michael-s-molina michael-s-molina merged commit a45d011 into apache:master Jun 23, 2022
michael-s-molina pushed a commit that referenced this pull request Jun 23, 2022
Recent commit to sort alphanumeric columns via case insensitive
comparison broke the multi-column sort option. React-table only sorts
by the second (or third...) column if the first column matches.
Since the alphanumeric sort only returned -1 or 1, it never would move
to the subsequent columns when the earlier column values matched.

(cherry picked from commit a45d011)
michael-s-molina pushed a commit that referenced this pull request Jun 28, 2022
Recent commit to sort alphanumeric columns via case insensitive
comparison broke the multi-column sort option. React-table only sorts
by the second (or third...) column if the first column matches.
Since the alphanumeric sort only returned -1 or 1, it never would move
to the subsequent columns when the earlier column values matched.

(cherry picked from commit a45d011)
@mistercrunch mistercrunch added 🍒 2.0.0 🍒 2.0.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L v2.0 🍒 2.0.0 🍒 2.0.1 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants