Skip to content

Use history.replaceState when updating URL hash on /faq - #95

Open
lewisdoesstuff wants to merge 1 commit into
Vencord:mainfrom
lewisdoesstuff:update-faq-history-handling
Open

Use history.replaceState when updating URL hash on /faq#95
lewisdoesstuff wants to merge 1 commit into
Vencord:mainfrom
lewisdoesstuff:update-faq-history-handling

Conversation

@lewisdoesstuff

Copy link
Copy Markdown

Currently, this uses location.hash = ${faqTitle}, which pushes a new history entry when opening or closing an FAQ section

If a user opens a bunch of the FAQ questions, the back button seemingly stops working, as there are history entries for the /faq page for every opened FAQ.

The page doesn't actually re-open the previous FAQ when pressing back, however, as the check for a hash fragment is only done on initial render.

Updated this to use history.replaceState instead, replacing the history entry with the current open FAQ hash fragment, ensuring only one history entry for the page, regardless of how many interactions there were.

Currently, this uses `location.hash = ${faqTitle}`, which pushes a new history entry when opening or closing an FAQ section

If a user opens a bunch of the FAQ questions, the back button seemingly stops working, as there are history entries for the `/faq` page for every opened FAQ.

The page doesn't actually re-open the previous FAQ when pressing back, however, as the check for a hash fragment is only done on initial render.

Updated this to use `history.replaceState` instead, replacing the history entry with the current open FAQ hash fragment, ensuring only one history entry for the page, regardless of how many interactions there were.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant