Skip to content

Commit

Permalink
Merge pull request #28826 from SkReD/fix-docs-anchor-scroll
Browse files Browse the repository at this point in the history
Blocks: Fix scroll to non-ascii anchors
  • Loading branch information
ndelangen authored Aug 19, 2024
2 parents 2b9141a + d20b3c6 commit 004df0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions code/addons/docs/template/stories/docs2/UtfSymbolScroll.mdx
Original file line number Diff line number Diff line change
@@ -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 (абвг)
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/DocsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 004df0c

Please sign in to comment.