Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(search): errors not displayed (closes #8704)
Elian Doranb09ef222f504
diff --git a/apps/client/src/widgets/ribbon/SearchDefinitionOptions.tsx b/apps/client/src/widgets/ribbon/SearchDefinitionOptions.tsxindex 90bea4ce23..02b52bf9e3 100644--- a/apps/client/src/widgets/ribbon/SearchDefinitionOptions.tsx+++ b/apps/client/src/widgets/ribbon/SearchDefinitionOptions.tsx@@ -7,6 +7,7 @@ import FNote from "../../entities/fnote";import { removeOwnedAttributesByNameOrType } from "../../services/attributes";import { t } from "../../services/i18n";import server from "../../services/server";+import Admonition from "../react/Admonition";import FormSelect from "../react/FormSelect";import FormTextArea from "../react/FormTextArea";import FormTextBox from "../react/FormTextBox";@@ -154,64 +155,56 @@ function SearchStringOption({ note, refreshResults, error, ...restProps }: Searc}}, 1000);- // React to errors- const { showTooltip, hideTooltip } = useTooltip(inputRef, {- trigger: "manual",- title: `${t("search_string.error", { error: error?.message })}`,- html: true,- placement: "bottom"- });-// Auto-focus.useEffect(() => inputRef.current?.focus(), []);- useEffect(() => {- if (error) {- showTooltip();- setTimeout(() => hideTooltip(), 4000);- } else {- hideTooltip();- }- }, [ error ]);-- return <SearchOption- title={t("search_string.title_column")}- help={<>- <strong>{t("search_string.search_syntax")}</strong> - {t("search_string.also_see")} <a href="#" data-help-page="search.html">{t("search_string.complete_help")}</a>- <ul style="marigin-bottom: 0;">- <li>{t("search_string.full_text_search")}</li>- <li><code>#abc</code> - {t("search_string.label_abc")}</li>- <li><code>#year = 2019</code> - {t("search_string.label_year")}</li>- <li><code>#rock #pop</code> - {t("search_string.label_rock_pop")}</li>- <li><code>#rock or #pop</code> - {t("search_string.label_rock_or_pop")}</li>- <li><code>#year <= 2000</code> - {t("search_string.label_year_comparison")}</li>- <li><code>note.dateCreated >= MONTH-1</code> - {t("search_string.label_date_created")}</li>- </ul>- </>}- note={note} {...restProps}- >- <FormTextArea- inputRef={inputRef}- className="search-string"- placeholder={t("search_string.placeholder")}- currentValue={searchString ?? ""}- onChange={text => {- currentValue.current = text;- spacedUpdate.scheduleUpdate();- }}- onKeyDown={async (e) => {- if (e.key === "Enter") {- e.preventDefault();+ return <>+ <SearchOption+ title={t("search_string.title_column")}+ help={<>+ <strong>{t("search_string.search_syntax")}</strong> - {t("search_string.also_see")} <a href="#" data-help-page="search.html">{t("search_string.complete_help")}</a>+ <ul style="marigin-bottom: 0;">+ <li>{t("search_string.full_text_search")}</li>+ <li><code>#abc</code> - {t("search_string.label_abc")}</li>+ <li><code>#year = 2019</code> - {t("search_string.label_year")}</li>+ <li><code>#rock #pop</code> - {t("search_string.label_rock_pop")}</li>+ <li><code>#rock or #pop</code> - {t("search_string.label_rock_or_pop")}</li>+ <li><code>#year <= 2000</code> - {t("search_string.label_year_comparison")}</li>+ <li><code>note.dateCreated >= MONTH-1</code> - {t("search_string.label_date_created")}</li>+ </ul>+ </>}+ note={note} {...restProps}+ >+ <FormTextArea+ inputRef={inputRef}+ className="search-string"+ placeholder={t("search_string.placeholder")}+ currentValue={searchString ?? ""}+ onChange={text => {+ currentValue.current = text;+ spacedUpdate.scheduleUpdate();+ }}+ onKeyDown={async (e) => {+ if (e.key === "Enter") {+ e.preventDefault();- // this also in effect disallows new lines in query string.- // on one hand, this makes sense since search string is a label- // on the other hand, it could be nice for structuring long search string. It's probably a niche case though.- await spacedUpdate.updateNowIfNecessary();- refreshResults();- }- }}- />- </SearchOption>;+ // this also in effect disallows new lines in query string.+ // on one hand, this makes sense since search string is a label+ // on the other hand, it could be nice for structuring long search string. It's probably a niche case though.+ await spacedUpdate.updateNowIfNecessary();+ refreshResults();+ }+ }}+ />+ </SearchOption>+ {error?.message && (+ <tr>+ <td colspan={3}>+ <Admonition type="caution">{error.message}</Admonition>+ </td>+ </tr>+ )}+ </>;}function SearchScriptOption({ note, ...restProps }: SearchOptionProps) {diff --git a/apps/client/src/widgets/ribbon/SearchDefinitionTab.css b/apps/client/src/widgets/ribbon/SearchDefinitionTab.cssindex 967a9a2f70..118f61de27 100644--- a/apps/client/src/widgets/ribbon/SearchDefinitionTab.css+++ b/apps/client/src/widgets/ribbon/SearchDefinitionTab.css@@ -4,6 +4,12 @@width: 100%;border-collapse: separate;border-spacing: 10px;++ .admonition {+ margin-top: 0.25em;+ margin-bottom: 1em;+ text-wrap: wrap;+ }}.search-setting-table div {@@ -154,7 +160,7 @@ body.mobile .search-definition-widget {.search-setting-table tr.ancestor > td > div {flex-direction: column;align-items: flex-start !important;- }+ }.search-actions tr {border-bottom: 0;@@ -171,4 +177,4 @@ body.mobile .search-definition-widget {overflow: unset;height: unset !important;}-}\ No newline at end of file+}