Skip to content

Commit 5975ae1

Browse files
authored
Merge pull request #111 from data-driven-forms/fixed-anchor-scrolling
Fixed lazy loaded components anchor scrolling.
2 parents 73bd214 + 33dc9a9 commit 5975ae1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/react-renderer-demo/src/common/component/renderer-doc-page.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ const RendererDocPage = ({ match: { params: { component }}}) => {
3939
const [ Component, setComponent ] = useState();
4040
const classes = useStyles();
4141
useEffect(() => {
42-
const OtherComponent = lazy(() => import(`docs/components/${component}.md`));
42+
const OtherComponent = lazy(() => import(`docs/components/${component}.md`).then((m) => {
43+
setImmediate(() => {
44+
const h = window.location.hash;
45+
window.location.hash = '';
46+
window.location.hash = h.replace('#', '');
47+
});
48+
return m;
49+
}));
50+
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
4351
setComponent(OtherComponent);
4452
}, [ component ]);
4553
return (

0 commit comments

Comments
 (0)