Skip to content

Commit 70d7ad0

Browse files
authored
fix(jump_to): fix issue where attributes/tags don't show in results (#6752)
2 parents e793b2f + 513878d commit 70d7ad0

File tree

4 files changed

+130
-9
lines changed

4 files changed

+130
-9
lines changed

apps/client/src/services/note_autocomplete.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export interface Suggestion {
3636
commandId?: string;
3737
commandDescription?: string;
3838
commandShortcut?: string;
39+
attributeSnippet?: string;
40+
highlightedAttributeSnippet?: string;
3941
}
4042

4143
export interface Options {
@@ -323,7 +325,33 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
323325
html += '</div>';
324326
return html;
325327
}
326-
return `<span class="${suggestion.icon ?? "bx bx-note"}"></span> ${suggestion.highlightedNotePathTitle}`;
328+
// Add special class for search-notes action
329+
const actionClass = suggestion.action === "search-notes" ? "search-notes-action" : "";
330+
331+
// Choose appropriate icon based on action
332+
let iconClass = suggestion.icon ?? "bx bx-note";
333+
if (suggestion.action === "search-notes") {
334+
iconClass = "bx bx-search";
335+
} else if (suggestion.action === "create-note") {
336+
iconClass = "bx bx-plus";
337+
} else if (suggestion.action === "external-link") {
338+
iconClass = "bx bx-link-external";
339+
}
340+
341+
// Simplified HTML structure without nested divs
342+
let html = `<div class="note-suggestion ${actionClass}">`;
343+
html += `<span class="${iconClass}" style="display: inline-block; width: 16px; vertical-align: top;"></span>`;
344+
html += `<span style="display: inline-block; width: calc(100% - 20px); padding-left: 4px;">`;
345+
html += `<span class="search-result-title" style="display: block;">${suggestion.highlightedNotePathTitle}</span>`;
346+
347+
// Add attribute snippet inline if available
348+
if (suggestion.highlightedAttributeSnippet) {
349+
html += `<span style="display: block; font-size: 0.8em; color: var(--muted-text-color); opacity: 0.6; line-height: 1;" class="search-result-attributes">${suggestion.highlightedAttributeSnippet}</span>`;
350+
}
351+
352+
html += `</span>`;
353+
html += `</div>`;
354+
return html;
327355
}
328356
},
329357
// we can't cache identical searches because notes can be created / renamed, new recent notes can be added

apps/client/src/stylesheets/style.css

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,20 +1795,69 @@ textarea {
17951795
font-size: 1em;
17961796
}
17971797

1798+
.jump-to-note-dialog .modal-dialog {
1799+
max-width: 900px;
1800+
width: 90%;
1801+
}
1802+
17981803
.jump-to-note-dialog .modal-header {
17991804
align-items: center;
18001805
}
18011806

18021807
.jump-to-note-dialog .modal-body {
18031808
padding: 0;
1809+
min-height: 200px;
18041810
}
18051811

18061812
.jump-to-note-results .aa-dropdown-menu {
1807-
max-height: 40vh;
1813+
max-height: calc(80vh - 200px);
1814+
width: 100%;
1815+
max-width: none;
1816+
overflow-y: auto;
1817+
overflow-x: hidden;
1818+
text-overflow: ellipsis;
1819+
box-shadow: none;
1820+
}
1821+
1822+
.jump-to-note-results {
1823+
width: 100%;
18081824
}
18091825

18101826
.jump-to-note-results .aa-suggestions {
1811-
padding: 1rem;
1827+
padding: 0;
1828+
width: 100%;
1829+
}
1830+
1831+
.jump-to-note-results .aa-dropdown-menu .aa-suggestion {
1832+
white-space: normal;
1833+
padding: 2px 12px !important;
1834+
line-height: 1.1;
1835+
position: relative;
1836+
border-radius: 0;
1837+
margin: 0 !important;
1838+
}
1839+
1840+
.jump-to-note-results .note-suggestion {
1841+
margin: 0;
1842+
padding: 0;
1843+
line-height: 1;
1844+
}
1845+
1846+
.jump-to-note-results .aa-suggestion:not(:last-child)::after {
1847+
display: none; /* Remove dividers for more compact look */
1848+
}
1849+
1850+
.jump-to-note-results .aa-suggestion:last-child::after {
1851+
display: none;
1852+
}
1853+
1854+
.jump-to-note-results .aa-suggestion.disabled::after {
1855+
display: none;
1856+
}
1857+
1858+
.jump-to-note-results .aa-dropdown-menu .aa-suggestion:hover,
1859+
.jump-to-note-results .aa-dropdown-menu .aa-cursor {
1860+
background-color: var(--hover-item-background-color, #f8f9fa);
18121861
}
18131862

18141863
/* Command palette styling */
@@ -1826,8 +1875,24 @@ textarea {
18261875

18271876
.jump-to-note-dialog .aa-cursor .command-suggestion,
18281877
.jump-to-note-dialog .aa-suggestion:hover .command-suggestion {
1829-
border-left-color: var(--link-color);
1830-
background-color: var(--hover-background-color);
1878+
background-color: transparent;
1879+
}
1880+
1881+
.jump-to-note-dialog .show-in-full-search,
1882+
.jump-to-note-results .show-in-full-search {
1883+
border-top: 1px solid var(--main-border-color);
1884+
padding-top: 12px;
1885+
margin-top: 12px;
1886+
}
1887+
1888+
.jump-to-note-results .aa-suggestion .search-notes-action {
1889+
border-top: 1px solid var(--main-border-color);
1890+
margin-top: 8px;
1891+
padding-top: 8px;
1892+
}
1893+
1894+
.jump-to-note-results .aa-suggestion:has(.search-notes-action)::after {
1895+
display: none;
18311896
}
18321897

18331898
.jump-to-note-dialog .command-icon {
@@ -2284,7 +2349,8 @@ footer.webview-footer button {
22842349

22852350
/* Search result highlighting */
22862351
.search-result-title b,
2287-
.search-result-content b {
2352+
.search-result-content b,
2353+
.search-result-attributes b {
22882354
font-weight: 900;
22892355
color: var(--admonition-warning-accent-color);
22902356
}

apps/client/src/stylesheets/theme-next/base.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ body.mobile .dropdown-menu .dropdown-item.submenu-open .dropdown-toggle::after {
538538
/* List item */
539539
.jump-to-note-dialog .aa-suggestions div,
540540
.note-detail-empty .aa-suggestions div {
541-
border-radius: 6px;
542-
padding: 6px 12px;
541+
border-radius: 0;
542+
padding: 12px 16px;
543543
color: var(--menu-text-color);
544544
cursor: default;
545545
}

apps/client/src/widgets/dialogs/jump_to_note.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import appContext from "../../components/app_context";
99
import commandRegistry from "../../services/command_registry";
1010
import { refToJQuerySelector } from "../react/react_utils";
1111
import useTriliumEvent from "../react/hooks";
12+
import shortcutService from "../../services/shortcuts";
1213

1314
const KEEP_LAST_SEARCH_FOR_X_SECONDS = 120;
1415

@@ -83,6 +84,27 @@ function JumpToNoteDialogComponent() {
8384
$autoComplete
8485
.trigger("focus")
8586
.trigger("select");
87+
88+
// Add keyboard shortcut for full search
89+
shortcutService.bindElShortcut($autoComplete, "ctrl+return", () => {
90+
if (!isCommandMode) {
91+
showInFullSearch();
92+
}
93+
});
94+
}
95+
96+
async function showInFullSearch() {
97+
try {
98+
setShown(false);
99+
const searchString = actualText.current?.trim();
100+
if (searchString && !searchString.startsWith(">")) {
101+
await appContext.triggerCommand("searchNotes", {
102+
searchString
103+
});
104+
}
105+
} catch (error) {
106+
console.error("Failed to trigger full search:", error);
107+
}
86108
}
87109

88110
return (
@@ -108,7 +130,12 @@ function JumpToNoteDialogComponent() {
108130
/>}
109131
onShown={onShown}
110132
onHidden={() => setShown(false)}
111-
footer={!isCommandMode && <Button className="show-in-full-text-button" text={t("jump_to_note.search_button")} keyboardShortcut="Ctrl+Enter" />}
133+
footer={!isCommandMode && <Button
134+
className="show-in-full-text-button"
135+
text={t("jump_to_note.search_button")}
136+
keyboardShortcut="Ctrl+Enter"
137+
onClick={showInFullSearch}
138+
/>}
112139
show={shown}
113140
>
114141
<div className="algolia-autocomplete-container jump-to-note-results" ref={containerRef}></div>

0 commit comments

Comments
 (0)