From 47e56a8ed3e3aa4ebad7fc6b4345ab8bcd79f40b Mon Sep 17 00:00:00 2001 From: istarkov Date: Mon, 26 Jun 2023 20:32:12 +0300 Subject: [PATCH 1/4] 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 e2c1539663..d10b1e3d7e 100644 --- a/packages/react-router-dom/index.tsx +++ b/packages/react-router-dom/index.tsx @@ -1384,7 +1384,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 763e7d7df16bfab62e539188b8b57efee68d91b0 Mon Sep 17 00:00:00 2001 From: istarkov Date: Mon, 26 Jun 2023 20:39:06 +0300 Subject: [PATCH 2/4] Add cla and changeset --- .changeset/dirty-coats-warn.md | 5 +++++ contributors.yml | 2 ++ 2 files changed, 7 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 ff676b1da3..7f934ccd80 100644 --- a/contributors.yml +++ b/contributors.yml @@ -222,3 +222,5 @@ - yionr - yuleicul - zheng-chuang +- holynewbie +- istarkov From 7eeb6ec17205a74123770a91920031c0f8bcb6af Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 7 Jul 2023 10:11:09 -0400 Subject: [PATCH 3/4] Lower to patch --- .changeset/decode-hash-scroll.md | 5 +++++ .changeset/dirty-coats-warn.md | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 .changeset/decode-hash-scroll.md delete mode 100644 .changeset/dirty-coats-warn.md diff --git a/.changeset/decode-hash-scroll.md b/.changeset/decode-hash-scroll.md new file mode 100644 index 0000000000..212990fbba --- /dev/null +++ b/.changeset/decode-hash-scroll.md @@ -0,0 +1,5 @@ +--- +"react-router-dom": patch +--- + +Properly decode element id when emulating hash scrolling via `` diff --git a/.changeset/dirty-coats-warn.md b/.changeset/dirty-coats-warn.md deleted file mode 100644 index 6e46b03b0c..0000000000 --- a/.changeset/dirty-coats-warn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"react-router-dom": minor ---- - -Fix elementId not decoded when emulate native hash scroll From ea1a6ab989a2fec80618b7242d57cc0250236809 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 7 Jul 2023 10:16:23 -0400 Subject: [PATCH 4/4] Remove duped contributor --- contributors.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/contributors.yml b/contributors.yml index 7f934ccd80..69cdb30698 100644 --- a/contributors.yml +++ b/contributors.yml @@ -222,5 +222,4 @@ - yionr - yuleicul - zheng-chuang -- holynewbie - istarkov