mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
fix(ui): don't remove ?q= from query args when filter list is empty
This commit is contained in:
committed by
Łukasz Mierzwa
parent
eef3d675d6
commit
75eeaf233c
@@ -66,16 +66,12 @@ function DecodeLocationSearch(searchString) {
|
||||
|
||||
function UpdateLocationSearch(newParams) {
|
||||
const baseURLWithoutSearch = window.location.href.split("?")[0];
|
||||
const newSearch = FormatAPIFilterQuery(newParams.q || []);
|
||||
if (newSearch !== "") {
|
||||
window.history.pushState(
|
||||
null,
|
||||
null,
|
||||
`${baseURLWithoutSearch}?${newSearch}`
|
||||
);
|
||||
} else {
|
||||
window.history.pushState(null, null, baseURLWithoutSearch);
|
||||
}
|
||||
const newSearch = FormatAPIFilterQuery(newParams.q);
|
||||
window.history.pushState(
|
||||
null,
|
||||
null,
|
||||
`${baseURLWithoutSearch}?${newSearch || "q="}`
|
||||
);
|
||||
}
|
||||
|
||||
const AlertStoreStatuses = Object.freeze({
|
||||
|
||||
@@ -383,13 +383,18 @@ describe("UpdateLocationSearch", () => {
|
||||
|
||||
it("{a: foo} is not pushed to location.search", () => {
|
||||
UpdateLocationSearch({ a: "foo" });
|
||||
expect(window.location.search).toBe("");
|
||||
expect(window.location.search).toBe("?q=");
|
||||
});
|
||||
|
||||
it("{a: foo, q: bar} is pushed to location.search", () => {
|
||||
UpdateLocationSearch({ a: "foo", q: "bar" });
|
||||
expect(window.location.search).toBe("?q=bar");
|
||||
});
|
||||
|
||||
it("{q: [1, 2]} is pushed to location.search", () => {
|
||||
UpdateLocationSearch({ q: ["1", "2"] });
|
||||
expect(window.location.search).toBe("?q=1&q=2");
|
||||
});
|
||||
});
|
||||
|
||||
describe("AlertStore.fetch", () => {
|
||||
|
||||
Reference in New Issue
Block a user