Skip to content

Commit

Permalink
fix(docs): ensure page scrolls to anchor on load when linked
Browse files Browse the repository at this point in the history
  • Loading branch information
Kadirsaglm authored and matyasf committed Sep 12, 2024
1 parent ef97c7c commit 6928c97
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/__docs__/src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,10 @@ class App extends Component<AppProps, AppState> {
fetch('markdown-and-sources-data.json', { signal })
.then((response) => response.json())
.then((docsData) => {
this.setState(
{
docsData,
themeKey: Object.keys(docsData.themes)[0]
},
this.scrollToElement
)
this.setState({
docsData,
themeKey: Object.keys(docsData.themes)[0]
})
})
.catch(errorHandler)
}
Expand Down Expand Up @@ -443,7 +440,12 @@ class App extends Component<AppProps, AppState> {
}
// eslint-disable-next-line no-param-reassign
data.children = children
this.setState({ currentDocData: data })
this.setState(
{
currentDocData: data
},
this.scrollToElement
)
})
return (
<View as="div" padding="xx-large 0">
Expand Down

0 comments on commit 6928c97

Please sign in to comment.