Skip to content

Commit

Permalink
fix: a bug 4956 (#6778)
Browse files Browse the repository at this point in the history
Co-authored-by: wuls <linsheng.wu@beantechs.com>
  • Loading branch information
JerryWu1234 and wuls committed Sep 11, 2024
1 parent b4cd308 commit ee24c89
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/popular-dragons-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': path
---

fix: SSG Link componet strips search parameters
4 changes: 3 additions & 1 deletion packages/qwik-city/src/runtime/src/qwik-city-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ export const QwikCityProvider = component$<QwikCityProps>((props) => {
const [routeName, params, mods, menu] = loadedRoute;
const contentModules = mods as ContentModule[];
const pageModule = contentModules[contentModules.length - 1] as PageModule;

if (navigation.dest.search) {
trackUrl.search = navigation.dest.search;
}
// Update route location
routeLocation.prevUrl = prevUrl;
routeLocation.url = trackUrl;
Expand Down
17 changes: 17 additions & 0 deletions starters/apps/qwikcity-test/src/routes/issue4956/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { component$, useStore, useTask$ } from "@builder.io/qwik";
import { useLocation } from "@builder.io/qwik-city";

export default component$((props) => {
const loc = useLocation();
const state = useStore({ id: "" });
useTask$(({ track }) => {
track(() => loc.url.searchParams);
state.id = loc.url.searchParams.get("id") || "";
});
return (
<div>
<h1>Issue 4956</h1>
<div id="routeId">{state.id}</div>
</div>
);
});
7 changes: 7 additions & 0 deletions starters/e2e/qwikcity/nav.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ test.describe("actions", () => {
);
});

test("issue4956", async ({ page }) => {
await page.goto("/qwikcity-test/issue4956?id=1");
const textContent = await page.locator("#routeId");

await expect(textContent).toHaveText("1");
});

test("issue4531", async ({ page }) => {
const res = await page.goto("/qwikcity-test/issue4531/");
await expect(page.locator("#route")).toHaveText("should render");
Expand Down

0 comments on commit ee24c89

Please sign in to comment.