Change replacement to add a class in TableSort.svelte#2
Open
ploshadka wants to merge 1 commit intomattiash:masterfrom
ploshadka:master
Open
Change replacement to add a class in TableSort.svelte#2ploshadka wants to merge 1 commit intomattiash:masterfrom ploshadka:master
ploshadka wants to merge 1 commit intomattiash:masterfrom
ploshadka:master
Conversation
It was impossible to put classes on the th header. They were removed and replaced by another class. Because of this, the styles of the header didn't work.
|
This seems to apply both an ascending and descending class at the same time if any of the headers are toggled to both. |
| : CLASSNAME_ASC) | ||
| : CLASSNAME_ASC | ||
|
|
||
| th.classList.add('CLASSNAME_SORTABLE') |
There was a problem hiding this comment.
should be "th.classList.add(CLASSNAME_SORTABLE)" as this is currently adding a string instead of the "sortable" class
|
This also appears to leave the "ascending" or "descending" class on columns which are no longer being sorted. |
| for (let i = 0; i < th.length; i++) { | ||
| if (th[i].dataset.sort) { | ||
| th[i].className = CLASSNAME_SORTABLE | ||
| th[i].classList.add(CLASSNAME_SORTABLE) |
There was a problem hiding this comment.
Add the below to clear any leftover "ascending" or "descending" classes where there are no longer being sorted.
if (th[i].classList.contains(CLASSNAME_ASC)) {
th[i].classList.remove(CLASSNAME_ASC);
} else if (th[i].classList.contains(CLASSNAME_DESC)) {
th[i].classList.remove(CLASSNAME_DESC);
}
| ? CLASSNAME_DESC | ||
| : CLASSNAME_ASC) | ||
| : CLASSNAME_ASC | ||
|
|
There was a problem hiding this comment.
Add the below to ensure only "ascending" or "descending" is shown, not both:
th.classList.remove(
descAsc == CLASSNAME_ASC ? CLASSNAME_DESC : CLASSNAME_ASC
);
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.
It was impossible to put classes on the th header. They were removed and replaced by another class. Because of this, the styles of the header didn't work.