From ff9bd8b12334c60aee6d858aa0028f1b4862ed95 Mon Sep 17 00:00:00 2001 From: istarkov Date: Mon, 26 Jun 2023 20:32:12 +0300 Subject: [PATCH 1/2] Fix elementId from hash --- packages/react-router-dom/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-router-dom/index.tsx b/packages/react-router-dom/index.tsx index dc9edbeca8..df7281cb05 100644 --- a/packages/react-router-dom/index.tsx +++ b/packages/react-router-dom/index.tsx @@ -1354,7 +1354,9 @@ function useScrollRestoration({ // try to scroll to the hash if (location.hash) { - let el = document.getElementById(location.hash.slice(1)); + let el = document.getElementById( + decodeURIComponent(location.hash.slice(1)) + ); if (el) { el.scrollIntoView(); return; From e4f83b4edbb9232a1c3ad806d3996f2976801319 Mon Sep 17 00:00:00 2001 From: istarkov Date: Mon, 26 Jun 2023 20:39:06 +0300 Subject: [PATCH 2/2] Add cla and changeset --- .changeset/dirty-coats-warn.md | 5 +++++ contributors.yml | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/dirty-coats-warn.md diff --git a/.changeset/dirty-coats-warn.md b/.changeset/dirty-coats-warn.md new file mode 100644 index 0000000000..6e46b03b0c --- /dev/null +++ b/.changeset/dirty-coats-warn.md @@ -0,0 +1,5 @@ +--- +"react-router-dom": minor +--- + +Fix elementId not decoded when emulate native hash scroll diff --git a/contributors.yml b/contributors.yml index c32eacce01..1c28dfdb96 100644 --- a/contributors.yml +++ b/contributors.yml @@ -219,3 +219,4 @@ - yuleicul - zheng-chuang - holynewbie +- istarkov