paoloricciuti / sveltekit-search-params

The easiest way to read and WRITE from query parameters in sveltekit.
https://sveltekit-search-params.netlify.app
MIT License
478 stars 13 forks source link

fix: rework how defaults works #58

Closed paoloricciuti closed 8 months ago

paoloricciuti commented 8 months ago

This should close #41 and #49

I changed a bit how defaults works...there's still a navigation happenning if possible but the default value is still set as the value of the store. This helps with SSR and i removed the weird set of defaulted params which i guess is what was causing #41

Summary by CodeRabbit

changeset-bot[bot] commented 8 months ago

🦋 Changeset detected

Latest commit: eb5fa7ba9a72e97439a19f85ce7176d07c78b1f1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------------- | ----- | | sveltekit-search-params | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

coderabbitai[bot] commented 8 months ago

Walkthrough

The changes address the implementation of query parameters handling within a Svelte component, particularly focusing on default values and their application during client-side navigation. The updates involve importing new utilities from a library, initializing variables with default values, and reflecting these values in the DOM. Additionally, the underlying library code has been refactored to change how default values are managed, and tests have been added to ensure the correct behavior of these defaults during server-side rendering and client-side navigation.

Changes

File Path Change Summary
.../src/routes/default/+page.svelte Added handling of query parameters with default values and updated DOM to display them.
src/lib/sveltekit-search-params.ts Refactored logic for handling default values, removed defaultedParams.
tests/index.test.ts Added tests for default value behavior during SSR and client-side navigation.

Assessment against linked issues

Objective Addressed Explanation
#41: Default value not applied in a second client-side navigation The changes in the Svelte component and the library code suggest that the handling of default values has been revised to ensure they are applied consistently during client-side navigation.

Poem

In the code where queries abound,
A rabbit hopped and defaults found.
With each click and page anew,
Defaults apply, as they rightly do. 🐇💻✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - You can reply to a review comment made by CodeRabbit. - You can tag CodeRabbit on specific lines of code or files in the PR by tagging `@coderabbitai` in a comment. - You can tag `@coderabbitai` in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - The JSON schema for the configuration file is available [here](https://coderabbit.ai/integrations/coderabbit-overrides.v2.json). - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json`
netlify[bot] commented 8 months ago

Deploy Preview for sveltekit-search-params ready!

Name Link
Latest commit eb5fa7ba9a72e97439a19f85ce7176d07c78b1f1
Latest deploy log https://app.netlify.com/sites/sveltekit-search-params/deploys/657ec24e9d06920008b0e452
Deploy Preview https://deploy-preview-58--sveltekit-search-params.netlify.app/
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.