mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Merge pull request #28826 from SkReD/fix-docs-anchor-scroll
Blocks: Fix scroll to non-ascii anchors
This commit is contained in:
commit
004df0c0fb
14
code/addons/docs/template/stories/docs2/UtfSymbolScroll.mdx
vendored
Normal file
14
code/addons/docs/template/stories/docs2/UtfSymbolScroll.mdx
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { Meta } from '@storybook/addon-docs';
|
||||
|
||||
<Meta title="UtfSymbolsScroll" />
|
||||
|
||||
## Instruction
|
||||
|
||||
> Instruction below works only in iframe.html. Unknown code in normal mode (with manager) removes hash from url.
|
||||
|
||||
Click on [link](#anchor-with-utf-symbols-абвг). That will jump scroll to anchor after green block below. Then reload page and
|
||||
it should smooth-scroll to that anchor.
|
||||
|
||||
<div style={{ height: "1500px", background: "green", color: "white" }}>Space for scroll test</div>
|
||||
|
||||
## Anchor with utf symbols (абвг)
|
@ -41,7 +41,7 @@ export const DocsContainer: FC<PropsWithChildren<DocsContainerProps>> = ({
|
||||
try {
|
||||
url = new URL(globalWindow.parent.location.toString());
|
||||
if (url.hash) {
|
||||
const element = document.getElementById(url.hash.substring(1));
|
||||
const element = document.getElementById(decodeURIComponent(url.hash.substring(1)));
|
||||
if (element) {
|
||||
// Introducing a delay to ensure scrolling works when it's a full refresh.
|
||||
setTimeout(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user