Skip to content

Commit

Permalink
fix timeframe reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Loggy committed Jul 28, 2021
1 parent 9795d17 commit 98721fa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions webapp/javascript/components/TagsBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ function TagsBar({ tags, fetchTags, fetchTagValues, tagValuesLoading }) {
Object.keys(tags).forEach((tag) => {
if (url.search.includes(tag)) {
loadTagValues(tag);
setTagsValue(url.searchParams.get(tag));
setTagsValue(`{${tag}=${url.searchParams.get(tag)}}`);
}
});
}, [tags]);

useEffect(() => {
history.push(`/?${tagsValue.replace(/[{}]/g, "")}`);
const [name, value] = tagsValue.replace(/[{}]/g, "").split("=");
const url = new URL(window.location.href);
if (value) {
url.searchParams.set(name, value);
} else {
url.searchParams.delete(name);
}
history.push(url.search);
}, [tagsValue]);

return (
Expand Down

0 comments on commit 98721fa

Please sign in to comment.