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

Support query parameters in routes #752

Merged
merged 13 commits into from
Nov 12, 2024

Conversation

davidon-top
Copy link
Contributor

@davidon-top davidon-top commented Nov 3, 2024

closes: #130
also fixes bug that when going from a url with hash to a url with no hash (and with the same path) it causes a reload of the whole site (it was probably there before i started coding new features but i don't know for sure)

@davidon-top davidon-top marked this pull request as draft November 3, 2024 16:36
Copy link

codecov bot commented Nov 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 111 lines in your changes missing coverage. Please review.

Project coverage is 71.32%. Comparing base (eb134c8) to head (35a7cb9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/sycamore-router/src/router.rs 0.00% 111 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #752      +/-   ##
==========================================
- Coverage   72.35%   71.32%   -1.03%     
==========================================
  Files          45       45              
  Lines        6557     6648      +91     
==========================================
- Hits         4744     4742       -2     
- Misses       1813     1906      +93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidon-top davidon-top marked this pull request as ready for review November 3, 2024 16:51
@davidon-top
Copy link
Contributor Author

I couldn't find web tests for the router and i'm not sure if u want me to add them to sycamore web tests or create new web tests in sycamore-router (or not write tests at all), (i manually tested it at least)

@lukechu10
Copy link
Member

I couldn't find web tests for the router and i'm not sure if u want me to add them to sycamore web tests or create new web tests in sycamore-router (or not write tests at all), (i manually tested it at least)

I'm not actually sure how to create web tests in this case since navigating will take you away from the generated wasm test page and thus stop the test. It would be nice if we could find a way to test this but for now this is fine I think.

@davidon-top
Copy link
Contributor Author

personally i would test this with an e2e test using selenium (at my previous job (softwareag, working student) that is all i did)

@lukechu10
Copy link
Member

personally i would test this with an e2e test using selenium (at my previous job (softwareag, working student) that is all i did)

Yeah something like that would work but that probably belongs in another PR. I was hoping to get e2e tests for all the examples as well so we could just e2e test the router example for this case.

@lukechu10 lukechu10 self-requested a review November 3, 2024 20:02
Copy link
Member

@lukechu10 lukechu10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added an example of query parameters to the router example. Also left a few comments.

@davidon-top
Copy link
Contributor Author

i just realized i accidentally deleted the functions from my previous pr (prob during merge or stash pop)

@lukechu10
Copy link
Member

lukechu10 commented Nov 4, 2024

Ok I'm running into something a little weird where the query parameter seems to require two page navigations for it to be reset.

Recording.2024-11-04.mp4

I'm trying to figure out why now...

@lukechu10
Copy link
Member

Ah got it. It's because we're calling pathname.set before calling the history API, causing everything to be delayed by one.

@lukechu10 lukechu10 enabled auto-merge (squash) November 12, 2024 12:22
@lukechu10
Copy link
Member

I also updated the order in the naviagte_* fuctions which essentially have the same logic as the click handler. Eventually, it would be a good idea to refactor this a bit to remove the duplicate logic.

@lukechu10 lukechu10 merged commit 0e82e2e into sycamore-rs:main Nov 12, 2024
9 of 11 checks passed
@davidon-top davidon-top deleted the router_params branch November 12, 2024 12:35
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

Successfully merging this pull request may close these issues.

Support query parameters in routes
2 participants