Skip to content

Commit

Permalink
[learn] Fix hard reload or initial load not respecting filter hash (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewJakubowicz authored Nov 7, 2023
1 parent 2033a29 commit 397df96
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/lit-dev-content/src/pages/learn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ const initChipsFromURL = async (hash = window.location.hash) => {
(chip as FilterChip).selected =
kinds.length === 0 || kinds.includes(chipKind);
});

// Do not update hash to prevent an infinite loop.
updateContentFromChips(false);
};

// Handles forwads and back navigation between hashes
// Handle forwards and back navigation between hashes
window.addEventListener('hashchange', async (event: HashChangeEvent) => {
await initChipsFromURL(new URL(event.newURL).hash);
// Do not update hash to prevent an infinite loop.
await updateContentFromChips(false);
});

// Handles clicking a filter chip.
Expand Down

0 comments on commit 397df96

Please sign in to comment.