From c2d2063102270308e11725a50080352d956d6ae0 Mon Sep 17 00:00:00 2001 From: Henning Janssen Date: Mon, 20 Jun 2022 14:38:11 +0200 Subject: [PATCH 1/2] Fix insertion of toggle hint into nested spans This commit makes the query changing the text of the toggle button more specific to not insert the hint in unrelated spans that are nested in the toggleable region --- sphinx_togglebutton/_static/togglebutton.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx_togglebutton/_static/togglebutton.js b/sphinx_togglebutton/_static/togglebutton.js index 116a836..806a653 100644 --- a/sphinx_togglebutton/_static/togglebutton.js +++ b/sphinx_togglebutton/_static/togglebutton.js @@ -73,9 +73,9 @@ var initToggleItems = () => { } // Update the inner text for the proper hint if (details.open) { - summary.querySelector("span").innerText = toggleHintShow; + summary.querySelector("span[class=toggle-details__summary-text]").innerText = toggleHintShow; } else { - summary.querySelector("span").innerText = toggleHintHide; + summary.querySelector("span[class=toggle-details__summary-text]").innerText = toggleHintHide; } }); From 49ffaa2293122bf9d54595c19e4206e78f6be02a Mon Sep 17 00:00:00 2001 From: Henning Janssen Date: Mon, 20 Jun 2022 20:39:06 +0200 Subject: [PATCH 2/2] Use standard class selector --- sphinx_togglebutton/_static/togglebutton.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx_togglebutton/_static/togglebutton.js b/sphinx_togglebutton/_static/togglebutton.js index 806a653..c6ace7d 100644 --- a/sphinx_togglebutton/_static/togglebutton.js +++ b/sphinx_togglebutton/_static/togglebutton.js @@ -73,9 +73,9 @@ var initToggleItems = () => { } // Update the inner text for the proper hint if (details.open) { - summary.querySelector("span[class=toggle-details__summary-text]").innerText = toggleHintShow; + summary.querySelector("span.toggle-details__summary-text").innerText = toggleHintShow; } else { - summary.querySelector("span[class=toggle-details__summary-text]").innerText = toggleHintHide; + summary.querySelector("span.toggle-details__summary-text").innerText = toggleHintHide; } });