Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: Fix scroll to non-ascii anchors #28826

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading