diff --git a/packages/code-studio/src/styleguide/Grids.tsx b/packages/code-studio/src/styleguide/Grids.tsx index e7a6e61408..56234c6f8f 100644 --- a/packages/code-studio/src/styleguide/Grids.tsx +++ b/packages/code-studio/src/styleguide/Grids.tsx @@ -27,7 +27,6 @@ function Grids(): ReactElement { autoSelectRow: true, }); const [contextTheme] = useState>({ - font: '12px sans-serif', rowHeight: 40, }); return ( diff --git a/packages/code-studio/src/styleguide/SamplesMenu.tsx b/packages/code-studio/src/styleguide/SamplesMenu.tsx index ebf5150c00..c3707864d8 100644 --- a/packages/code-studio/src/styleguide/SamplesMenu.tsx +++ b/packages/code-studio/src/styleguide/SamplesMenu.tsx @@ -81,15 +81,25 @@ export function SamplesMenu(): JSX.Element { el.id = id; currentCategory.items.push({ id, label: el.textContent }); - - if (`#${id}` === window.location.hash) { - el.scrollIntoView(); - } }); setLinks(categories); }, []); + useEffect(() => { + const el = + window.location.hash === '' + ? null + : document.querySelector(window.location.hash); + + if (el) { + // Give everything a chance to render before scrolling + setTimeout(() => { + el.scrollIntoView(); + }, 0); + } + }, []); + const onAction = useCallback((key: Key) => { const id = String(key); const el = document.getElementById(id); diff --git a/tests/styleguide.spec.ts-snapshots/grids-async-firefox-linux.png b/tests/styleguide.spec.ts-snapshots/grids-async-firefox-linux.png index a6053e073b..c07844f4c2 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-async-firefox-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-async-firefox-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-async-webkit-linux.png b/tests/styleguide.spec.ts-snapshots/grids-async-webkit-linux.png index a5c10bd8c7..e094444a62 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-async-webkit-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-async-webkit-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-data-bar-firefox-linux.png b/tests/styleguide.spec.ts-snapshots/grids-data-bar-firefox-linux.png index e57ffc496d..4aa4e70ef2 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-data-bar-firefox-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-data-bar-firefox-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-data-bar-webkit-linux.png b/tests/styleguide.spec.ts-snapshots/grids-data-bar-webkit-linux.png index 2f0b56f955..9447659cbd 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-data-bar-webkit-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-data-bar-webkit-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-grid-firefox-linux.png b/tests/styleguide.spec.ts-snapshots/grids-grid-firefox-linux.png index a1b3d429cf..f58e989a36 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-grid-firefox-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-grid-firefox-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-grid-webkit-linux.png b/tests/styleguide.spec.ts-snapshots/grids-grid-webkit-linux.png index 52b02790fe..6a4217cd2d 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-grid-webkit-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-grid-webkit-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-quadrillion-firefox-linux.png b/tests/styleguide.spec.ts-snapshots/grids-quadrillion-firefox-linux.png index c279fb5842..770eebc102 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-quadrillion-firefox-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-quadrillion-firefox-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-quadrillion-webkit-linux.png b/tests/styleguide.spec.ts-snapshots/grids-quadrillion-webkit-linux.png index 5b0ab64594..4cd4bf74b6 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-quadrillion-webkit-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-quadrillion-webkit-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-static-firefox-linux.png b/tests/styleguide.spec.ts-snapshots/grids-static-firefox-linux.png index e4cd37190f..b441b705dd 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-static-firefox-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-static-firefox-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-static-webkit-linux.png b/tests/styleguide.spec.ts-snapshots/grids-static-webkit-linux.png index 31f33bbe1a..9ee9ee9ca2 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-static-webkit-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-static-webkit-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-tree-firefox-linux.png b/tests/styleguide.spec.ts-snapshots/grids-tree-firefox-linux.png index 62214e608c..e3e4be2056 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-tree-firefox-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-tree-firefox-linux.png differ diff --git a/tests/styleguide.spec.ts-snapshots/grids-tree-webkit-linux.png b/tests/styleguide.spec.ts-snapshots/grids-tree-webkit-linux.png index fcec072d92..6e77e50090 100644 Binary files a/tests/styleguide.spec.ts-snapshots/grids-tree-webkit-linux.png and b/tests/styleguide.spec.ts-snapshots/grids-tree-webkit-linux.png differ