authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2023-05-02 04:43:06+02:00
committergravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2023-05-02 04:43:06+02:00
logeab4cd7a66803809ca94a03adc8bbdefc87bd60b
treec91b0c229c4b7c7471419c4328b71ab75a9f44ff
parent6f1336a50c6c2d9498bb9b3fb291cb305688c1b9

autodoc: type "?" instead of opening help modal if search selected

The question mark character can appear in identifiers as part of the `@"syntax"` so we should allow typing it. Now, when the search is selected, "?" is entered instead. It also shouldn't be that common in general for the user to want to open the help modal.

1 files changed, 7 insertions(+), 1 deletions(-)

lib/docs/main.js+7-1
...@@ -127,16 +127,20 @@ const NAV_MODES = {...@@ -127,16 +127,20 @@ const NAV_MODES = {
127 window.guideSearch = guidesSearchIndex;127 window.guideSearch = guidesSearchIndex;
128 parseGuides();128 parseGuides();
129129
130 130 // identifiers can contain '?' so we want to allow typing
131 // the question mark when the search is focused instead of toggling the help modal
132 let canToggleHelpModal = true;
131133
132 domSearch.disabled = false;134 domSearch.disabled = false;
133 domSearch.addEventListener("keydown", onSearchKeyDown, false);135 domSearch.addEventListener("keydown", onSearchKeyDown, false);
134 domSearch.addEventListener("focus", ev => {136 domSearch.addEventListener("focus", ev => {
135 domSearchPlaceholder.classList.add("hidden");137 domSearchPlaceholder.classList.add("hidden");
138 canToggleHelpModal = false;
136 });139 });
137 domSearch.addEventListener("blur", ev => {140 domSearch.addEventListener("blur", ev => {
138 if (domSearch.value.length == 0)141 if (domSearch.value.length == 0)
139 domSearchPlaceholder.classList.remove("hidden");142 domSearchPlaceholder.classList.remove("hidden");
143 canToggleHelpModal = true;
140 });144 });
141 domSectSearchAllResultsLink.addEventListener('click', onClickSearchShowAllResults, false);145 domSectSearchAllResultsLink.addEventListener('click', onClickSearchShowAllResults, false);
142 function onClickSearchShowAllResults(ev) {146 function onClickSearchShowAllResults(ev) {
...@@ -4044,6 +4048,8 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {...@@ -4044,6 +4048,8 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
4044 }4048 }
4045 break;4049 break;
4046 case "?":4050 case "?":
4051 if (!canToggleHelpModal) break;
4052
4047 // toggle the help modal4053 // toggle the help modal
4048 if (!domHelpModal.classList.contains("hidden")) {4054 if (!domHelpModal.classList.contains("hidden")) {
4049 onEscape(ev);4055 onEscape(ev);