Skip to content

Commit

Permalink
reset scroll in Demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
sadiqkhoja committed Jul 12, 2024
1 parent 9e64b5d commit 3fc369a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/web-forms/src/OdkWebFormDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ const handleSubmit = () => {
const showForm = (form: [string, string]) => {
selectForm.value = form;
history.pushState({form: form }, "", "/" + form[0]);
window.scrollTo(0,0);
}
interface PopStateEventWithForm extends PopStateEvent {
state: {form: [string, string]};
}
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
window.addEventListener("popstate", (event:PopStateEventWithForm) => {
if(!event.state) {
selectForm.value = null;
Expand Down

0 comments on commit 3fc369a

Please sign in to comment.