-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HAI-1248 Fix document scroll position in forms
Fixed problem where form page in hanke form and cable report application form would not be scrolled to top when entering the form or changing form page. Made it so that window.scrollTo(0, 0) is called when MultipageForm component is mounted and unmounted and also when changing form page.
- Loading branch information
1 parent
bedc0f9
commit 5665870
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useEffect } from 'react'; | ||
|
||
/** | ||
* Scroll to top of window whenever component | ||
* using this hook mounts and unmounts. | ||
* Also return the scrollToTop function. | ||
*/ | ||
function useScrollToTop() { | ||
function scrollToTop() { | ||
window.scrollTo(0, 0); | ||
} | ||
|
||
useEffect(() => { | ||
scrollToTop(); | ||
|
||
return function cleanup() { | ||
scrollToTop(); | ||
}; | ||
}, []); | ||
|
||
return scrollToTop; | ||
} | ||
|
||
export default useScrollToTop; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters