Skip to content

Commit

Permalink
Merge pull request #279 from JaneliaSciComp/fix-project-type-btn-state
Browse files Browse the repository at this point in the history
fix: checks projectType url param on mount to update btns
  • Loading branch information
allison-truhlar authored Jul 24, 2024
2 parents 8ab814d + 8956248 commit fd62ee6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/stores/selectedProjectTypeStore.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { atom } from "nanostores";
import { atom, onMount } from "nanostores";

export const selectedProjectType = atom([]);

onMount(selectedProjectType, () => {
const currentProjectType = selectedProjectType.get();
let urlProjectType = [];
if (typeof window !== "undefined") {
const searchParams = new URLSearchParams(window.location.search);
urlProjectType = searchParams.getAll("projectType");
}
if ((currentProjectType.length === 0) & (urlProjectType.length > 0)) {
selectedProjectType.set(urlProjectType);
}
});

function updateProjectTypeSearchParams(updatedProjectType) {
// update URL search params
if (typeof window !== "undefined") {
Expand Down

0 comments on commit fd62ee6

Please sign in to comment.