diff --git a/CHANGES.rst b/CHANGES.rst
index ea855c69f..02cc27ef0 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -25,6 +25,8 @@ Bugs fixed
* #12162: Fix a performance regression in the C domain that has
been present since version 3.0.0.
Patch by Donald Hunter.
+* #12320: Fix removal of anchors from search summaries (regression in 7.3.0).
+ Patch by Will Lachance.
Testing
-------
diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js
index 92da3f8b2..eaed90953 100644
--- a/sphinx/themes/basic/static/searchtools.js
+++ b/sphinx/themes/basic/static/searchtools.js
@@ -178,7 +178,7 @@ const Search = {
htmlToText: (htmlString, anchor) => {
const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
- for (const removalQuery of [".headerlinks", "script", "style"]) {
+ for (const removalQuery of [".headerlink", "script", "style"]) {
htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
}
if (anchor) {
diff --git a/tests/js/searchtools.js b/tests/js/searchtools.js
index 4f9984dd4..99ebdafb1 100644
--- a/tests/js/searchtools.js
+++ b/tests/js/searchtools.js
@@ -100,15 +100,15 @@ describe("htmlToText", function() {
- Getting Started
+ Getting Started
Some text
- Other Section
+ Other Section
Other text
- Yet Another Section
+ Yet Another Section
More text