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

feat(admin-ui): Preset filters should preserve query parameters #3176

Conversation

taxilian
Copy link
Contributor

@taxilian taxilian commented Oct 31, 2024

Description

Any page that uses data-table2 with presets, when the presets change they lose any query parameters. This includes the currently set "display per page". This can be very frustrating if you use presets to switch quickly between groups of items which number more than 10 because you have to keep moving down and turning it back up.

This fix causes it to keep any existing query parameters except the "filters" and "page" parameters, which are the ones that it uses.

Breaking changes

No, just changed behavior

Screenshots

image

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases - Not applicable, AFAIK
  • I have updated the README if needed - Not applicable, AFAIK

Copy link

vercel bot commented Oct 31, 2024

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

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Nov 16, 2024 0:12am

@michaelbromley
Copy link
Member

Hi!

This is a good improvement but it seems to not work reliably in all cases, according to my testing.

  1. go to product list
  2. create a filter preset (exact type does not matter)
  3. navigate away from product list to another page
  4. return to product list
  5. set items per page to 25
  6. click the preset

You will see that the "perPage" query param is lost.

This can be solved by adding this to the onInit() method:

        // When any query param changes, we want to trigger change detection
        // so that the links for each preset are updated.
        this.route.queryParamMap
            .pipe(takeUntil(this.destroy$))
            .subscribe(() => this.changeDetectorRef.markForCheck());

@taxilian taxilian force-pushed the feature/datatable-feature-retainqueryparams branch from d41f30a to 7ffb82d Compare November 16, 2024 00:11
@taxilian
Copy link
Contributor Author

pushed a fix; thanks for taking the time to look at and test this. It's really slowing down some of our workflows =]

My last real experience with Angular was about 6 years ago, so I'm beyond rusty dealign with rxjs nonsense. I'm more of a vue fan myself =]

@michaelbromley michaelbromley merged commit 7a25bef into vendure-ecommerce:master Nov 29, 2024
29 of 30 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 29, 2024
@michaelbromley
Copy link
Member

Thank you, that works well now 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants