Merge pull request #28826 from SkReD/fix-docs-anchor-scroll

Blocks: Fix scroll to non-ascii anchors
This commit is contained in:
Norbert de Langen 2024-08-19 10:34:06 +02:00 committed by GitHub
commit 004df0c0fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View 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 (абвг)

View File

@ -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(() => {