Skip to content

Build your personal knowledge base with Trilium Notes

fix(popup-editor): let the quick editor cover a CKEditor dialog opened before it

Elian Dorandac2319ec01c
diff --git a/apps/client/src/widgets/dialogs/PopupEditor.css b/apps/client/src/widgets/dialogs/PopupEditor.css
index 496724b476..0819b0adc2 100644
--- a/apps/client/src/widgets/dialogs/PopupEditor.css
+++ b/apps/client/src/widgets/dialogs/PopupEditor.css
@@ -10,6 +10,8 @@ body.popup-editor-stacked .popup-editor-dialog { z-index: 1100; }
body.popup-editor-stacked .ck-clipboard-drop-target-line { z-index: 1101; }
.modal-backdrop.popup-editor-backdrop { z-index: 1099; }
+body.popup-editor-open .ck.ck-dialog-overlay.ck-dialog-behind-popup-editor { z-index: 997; }
+
body.desktop .modal.popup-editor-dialog .modal-dialog {
max-width: 75vw;
border-bottom-left-radius: var(--bs-modal-border-radius);
diff --git a/apps/client/src/widgets/dialogs/PopupEditor.tsx b/apps/client/src/widgets/dialogs/PopupEditor.tsx
index 5064a70812..ae7a6bfc8b 100644
--- a/apps/client/src/widgets/dialogs/PopupEditor.tsx
+++ b/apps/client/src/widgets/dialogs/PopupEditor.tsx
@@ -92,6 +92,18 @@ export default function PopupEditor() {
document.body.classList.toggle("popup-editor-stacked", shown && stacked);
}, [shown, stacked]);
+ // A CKEditor dialog — the AI assistant — stacks at `--ck-z-dialog` (9999), far above the 999
+ // this popup is deliberately held at so the editor's own panels can float over it. One already
+ // open belongs to the editor behind and has to give way; one opened later belongs to the editor
+ // *in* the popup and has to stay above it. Both are appended to `<body>`, so no selector tells
+ // them apart — but the one to demote is exactly the one standing when the popup opens.
+ useEffect(() => {
+ if (!shown) return;
+ const openDialog = document.querySelector(".ck-dialog-overlay");
+ openDialog?.classList.add("ck-dialog-behind-popup-editor");
+ return () => openDialog?.classList.remove("ck-dialog-behind-popup-editor");
+ }, [shown]);
+
// When stacked on top of another modal, raise this popup's own backdrop above
// the underlying modal. Bootstrap does not auto-increment z-index for stacked
// modals, and the appended `.modal-backdrop` is not individually addressable.