Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Move CKEditor dropdowns into top-layer if dialog is open

Oliver Günther570b5ee5a78b
diff --git a/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts b/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts
index 2adf852a046..8854f0c5d7d 100644
--- a/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts
+++ b/frontend/src/app/shared/components/editor/components/ckeditor/ckeditor-setup.service.ts
@@ -31,6 +31,7 @@ export class CKEditorSetupService {
public initialize() {
this.prefetch = this.load();
+ this.watchTopLayer();
}
/**
@@ -45,7 +46,8 @@ export class CKEditorSetupService {
* @returns {Promise<ICKEditorWatchdog>}
*/
public async create(
- wrapper:HTMLElement, context:ICKEditorContext,
+ wrapper:HTMLElement,
+ context:ICKEditorContext,
initialData:string|null = null,
):Promise<ICKEditorWatchdog> {
// Load the bundle and the matching locale, if found.
@@ -144,4 +146,31 @@ export class CKEditorSetupService {
pluginContext: window.OpenProject.pluginContext.value,
};
}
+
+ private watchTopLayer() {
+ const targetClassNames = ['ck-body-wrapper', 'ck-inspector-wrapper', 'ck-inspector-portal'];
+
+ const observer = new MutationObserver((mutations) => {
+ const dialog = document.querySelector('dialog[open]');
+ if (!dialog) {
+ return;
+ }
+
+ mutations.forEach((mutation) => {
+ mutation.addedNodes.forEach((node) => {
+ if (!(node instanceof HTMLElement)) {
+ return;
+ }
+
+ if (targetClassNames.some((className) => node.classList.contains(className))) {
+ dialog.append(node);
+ }
+ });
+ });
+ });
+
+ observer.observe(document.body, {
+ childList: true,
+ });
+ }
}