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

fixed blur event listener

Jonas Jabari0c127d910bda
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
index f464f20da61..1293a45374f 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
@@ -4,6 +4,7 @@ import {
ICKEditorInstance,
} from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types';
import { KeyCodes } from 'core-app/shared/helpers/keyCodes.enum';
+import { set } from 'lodash';
export default class IndexController extends Controller {
static values = {
@@ -140,8 +141,15 @@ export default class IndexController extends Controller {
private addBlurListener(editor:ICKEditorInstance) {
editor.listenTo(
editor.editing.view.document,
- 'blur',
- () => this.hideEditorIfEmpty(),
+ 'change:isFocused',
+ () => {
+ // without the timeout `isFocused` is still true even if the editor was blurred
+ // current limitation:
+ // clicking on empty toolbar space and the somewhere else on the page does not trigger the blur anymore
+ setTimeout(() => {
+ if (!editor.ui.focusTracker.isFocused) { this.hideEditorIfEmpty(); }
+ }, 100);
+ },
{ priority: 'highest' },
);
}