feat: add unsort state on 3rd column header click - #841
Open
Rawi2115 wants to merge 1 commit into
Open
Conversation
Sorting previously only toggled between two states per column: 1st click -> asc, 2nd click -> desc, 3rd click -> back to asc, with no way to fully clear a column's sort via the header. Add a third click state that clears sorting instead of cycling back to ascending. Following the pattern already used in a community workaround for this request, unsorted is represented with the existing DataTableSortStatus shape by setting columnAccessor to an empty string, rather than changing the type to allow undefined/null. This keeps direction always defined and avoids touching every downstream consumer of sortStatus. The header cell's existing icon logic already falls back to the unsorted icon whenever sortStatus.columnAccessor doesn't match the column's own accessor, so no rendering changes were needed there - an empty-string sentinel naturally satisfies that check for every column. Also updates the sorting example to explicitly handle the empty columnAccessor case, and adds a note to the sorting docs page explaining the new third-click behavior. Fixes icflorescu#812
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sorting previously only toggled between two states per column: 1st click -> asc, 2nd click -> desc, 3rd click -> back to asc, with no way to fully clear a column's sort via the header.
Add a third click state that clears sorting instead of cycling back to ascending. unsorting happens by setting the columnAccessor in the sort status to an empty string ("")
Also updates the sorting example to explicitly handle the empty columnAccessor case, and adds a note to the sorting docs page explaining the new third-click behavior.
Fixes #812