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

props.sort.order not updated while using the filter and pagination plugins #148

Open
Ennoriel opened this issue Aug 18, 2023 · 4 comments
Open

Comments

@Ennoriel
Copy link

Ennoriel commented Aug 18, 2023

Thanks for your awesome library! :)

I've been struggling to understand where my problem comes from. I am using the filter and pagination plugins in order to use the component asyncronously with a fetch call. At the moment I do not make any fetch call but fake it with a promise/setTimeout. When doing so, the value of props.sort.order is not fully updated (sometimes using it as the condition of an if block works).

here is a REPL with my code: https://svelte.dev/repl/5f845383976b49e3a5edb4a0ad9a1953?version=4.2.0 (the order indication "up" and "down" does not work)

Do you know where this behavior comes from?

There is a workaround using the table state.

@codenius
Copy link

codenius commented Sep 16, 2023

I experienced this issue too. Can you share the workaround, while it's not fixed yet?

@Ennoriel
Copy link
Author

Ennoriel commented Sep 21, 2023

@codenius You have access to a global sortKeys store: const { sortKeys } = pluginStates.sort;. You can use that to display anything you want

@hartwm
Copy link

hartwm commented Dec 22, 2023

came here for this

@codenius
Copy link

codenius commented Jan 31, 2024

@codenius You have access to a global sortKeys store: const { sortKeys } = pluginStates.sort;. You can use that to display anything you want

What's interesting although, that as soon as I add these to lines inside the script tag, it suddenly all works perfectly fine. There were no additional changes requierd in my case, which indicates a weird reactivity issue under the hood.
In another table hover, this trick didn't work.

const { sortKeys } = pluginStates.sort;
$: $sortKeys

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

No branches or pull requests

3 participants