Skip to content

Build your personal knowledge base with Trilium Notes

feat(search): put the add menu and search on one row

Elian Doranbe85fe5eb7d8
diff --git a/apps/client/src/widgets/search/SearchDefinition.css b/apps/client/src/widgets/search/SearchDefinition.css
index e36748ae2f..f12b62a107 100644
--- a/apps/client/src/widgets/search/SearchDefinition.css
+++ b/apps/client/src/widgets/search/SearchDefinition.css
@@ -49,9 +49,13 @@
margin: 0;
}
+ /* The add menu stands at the start of the row, the search button at its end. */
.search-definition-actions {
display: flex;
- justify-content: flex-end;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
}
}
diff --git a/apps/client/src/widgets/search/SearchDefinition.spec.tsx b/apps/client/src/widgets/search/SearchDefinition.spec.tsx
index 37823610e5..c04e0bbab0 100644
--- a/apps/client/src/widgets/search/SearchDefinition.spec.tsx
+++ b/apps/client/src/widgets/search/SearchDefinition.spec.tsx
@@ -50,15 +50,15 @@ describe("the search definition", () => {
expect(card).not.toBeNull();
expect(card?.querySelector(".tn-card-section.tn-card-option.searchString")).not.toBeNull();
- expect(card?.querySelector(".tn-card-section.search-definition-actions")).not.toBeNull();
- const addRow = card?.querySelector(".tn-card-section.search-definition-add");
- expect(addRow?.querySelectorAll(".dropdown")).toHaveLength(1);
+ const actionsRow = card?.querySelector(".tn-card-section.search-definition-actions");
+ expect(actionsRow?.querySelector(".search-definition-add")).not.toBeNull();
+ expect(actionsRow?.querySelector(".tn-split-button")).not.toBeNull();
});
it("offers the unused options and the bulk actions from the same menu", async () => {
const container = renderDefinition();
- const toggle = container.querySelector<HTMLButtonElement>(".search-definition-add .dropdown button");
+ const toggle = container.querySelector<HTMLButtonElement>(".search-definition-add button");
await act(async () => toggle?.click());
const menu = document.querySelector(".action-add-menu");
diff --git a/apps/client/src/widgets/search/SearchDefinition.tsx b/apps/client/src/widgets/search/SearchDefinition.tsx
index f28ba9f6df..6fc6120f56 100644
--- a/apps/client/src/widgets/search/SearchDefinition.tsx
+++ b/apps/client/src/widgets/search/SearchDefinition.tsx
@@ -100,15 +100,14 @@ export default function SearchDefinition({ note, ntxId }: {
<BulkActionsList note={note} />
- <CardSection className="search-definition-add">
+ <CardSection className="search-definition-actions">
<AddSearchOptionButton note={note} options={searchOptions?.availableOptions ?? []} />
+ <SearchButtonBar
+ note={note}
+ refreshResults={refreshResults}
+ savePendingOptions={savePendingOptions}
+ />
</CardSection>
-
- <SearchButtonBar
- note={note}
- refreshResults={refreshResults}
- savePendingOptions={savePendingOptions}
- />
</Card>
)}
</div>
@@ -140,16 +139,14 @@ function SearchButtonBar({ note, refreshResults, savePendingOptions }: {
}
return (
- <CardSection className="search-definition-actions">
- <SplitButton
- text={t("search_definition.search_button")} icon="bx bx-search"
- size="micro"
- onClick={refreshResults}
- >
- <FormListItem icon="bx bxs-zap" onClick={searchAndExecuteActions}>{t("search_definition.search_execute")}</FormListItem>
- {note.isHiddenCompletely() && <FormListItem icon="bx bx-save" onClick={saveSearchNote}>{t("search_definition.save_to_note")}</FormListItem>}
- </SplitButton>
- </CardSection>
+ <SplitButton
+ text={t("search_definition.search_button")} icon="bx bx-search"
+ size="micro"
+ onClick={refreshResults}
+ >
+ <FormListItem icon="bx bxs-zap" onClick={searchAndExecuteActions}>{t("search_definition.search_execute")}</FormListItem>
+ {note.isHiddenCompletely() && <FormListItem icon="bx bx-save" onClick={saveSearchNote}>{t("search_definition.save_to_note")}</FormListItem>}
+ </SplitButton>
);
}
@@ -212,6 +209,7 @@ function AddSearchOptionButton({ note, options }: { note: FNote; options: Search
return (
<Dropdown
+ className="search-definition-add"
buttonClassName="btn-secondary btn-micro"
text={<><Icon icon="bx bx-plus" />{" "}{t("search_definition.add_search_option")}</>}
noSelectButtonStyle