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(attributes): keep the peeked sidebar open while using the attribute popup
Elian Dorandc0cd6cf808c
diff --git a/apps/client/src/widgets/react/peek_pane.spec.tsx b/apps/client/src/widgets/react/peek_pane.spec.tsxindex 8ae64d92c3..3cb50516fe 100644--- a/apps/client/src/widgets/react/peek_pane.spec.tsx+++ b/apps/client/src/widgets/react/peek_pane.spec.tsx@@ -127,6 +127,10 @@ describe("usePeekDismiss", () => {document.body.innerHTML = `<div id="right-pane"></div><ul class="dropdown-menu"></ul>+ <div class="attr-detail"><input class="attr-input" /></div>+ <div class="form-autocomplete-dropdown"><li class="suggestion"></li></div>+ <div class="aa-dropdown-menu"><div class="aa-suggestion"></div></div>+ <div id="context-menu-container"><li class="menu-item"></li></div><div id="center-pane"></div>`;const onDismiss = vi.fn();@@ -136,6 +140,12 @@ describe("usePeekDismiss", () => {document.querySelector("#right-pane")?.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));// ...as does a default popup root (not in keepOpenSelector, but in the built-in allowlist).document.querySelector(".dropdown-menu")?.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));+ // Body-portalled popups spawned from within the pane keep it open too: the attribute+ // detail popup and its fields, both autocomplete dropdowns, and the context menu.+ document.querySelector(".attr-input")?.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));+ document.querySelector(".suggestion")?.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));+ document.querySelector(".aa-suggestion")?.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));+ document.querySelector(".menu-item")?.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));expect(onDismiss).not.toHaveBeenCalled();// A press anywhere else dismisses.diff --git a/apps/client/src/widgets/react/peek_pane.ts b/apps/client/src/widgets/react/peek_pane.tsindex 52f99f845e..7efdadd6c3 100644--- a/apps/client/src/widgets/react/peek_pane.ts+++ b/apps/client/src/widgets/react/peek_pane.ts@@ -106,8 +106,11 @@ export function usePaneMode(visibleOption: OptionNames): PaneModeController {}// App-wide popup roots that render outside the pane (on document.body) but must NOT dismiss a peek:-// resize gutters, Bootstrap dropdowns/tooltips/modals/popovers, CKEditor balloons, Flatpickr calendars.-const DEFAULT_KEEP_OPEN_SELECTOR = ".gutter, .dropdown-menu, .tooltip, .modal, .popover, .ck-balloon-panel, .ck-body, .flatpickr-calendar";+// resize gutters, Bootstrap dropdowns/tooltips/modals (and their backdrop)/popovers, CKEditor balloons,+// Flatpickr calendars, the attribute detail popup, the context menu, and both autocomplete dropdowns+// (Preact `FormAutocomplete` and the jQuery note autocomplete).+const DEFAULT_KEEP_OPEN_SELECTOR = ".gutter, .dropdown-menu, .tooltip, .modal, .modal-backdrop, .popover, .ck-balloon-panel, .ck-body, .flatpickr-calendar, "+ + ".attr-detail, #context-menu-container, .form-autocomplete-dropdown, .aa-dropdown-menu";/** Whether an event target lies within the peek pane or an allowlisted popup (i.e. should keep it open). */export function isWithinPeek(target: EventTarget | null, keepOpenSelector: string): boolean {