-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding a skip to search anchor (#850)
Co-authored-by: Luke Karrys <[email protected]>
- Loading branch information
1 parent
298c866
commit e388aee
Showing
4 changed files
with
51 additions
and
34 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 |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import {SKIP_TO_SEARCH_ID} from './src/constants' | ||
|
||
export {default as wrapPageElement} from './src/page' | ||
export {default as wrapRootElement} from './src/root' | ||
|
||
export const shouldUpdateScroll = ({routerProps}) => { | ||
const {scrollUpdate = true} = routerProps.location.state ?? {} | ||
return scrollUpdate | ||
} | ||
|
||
export const onRouteUpdate = ({location, prevLocation}) => { | ||
if (location.hash === `#${SKIP_TO_SEARCH_ID}` && prevLocation?.hash !== `#${SKIP_TO_SEARCH_ID}`) { | ||
document.getElementById(SKIP_TO_SEARCH_ID)?.focus() | ||
} | ||
} |
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
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