From 7960cde21846a3a481053dabfb05a9add0eec70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Wed, 27 Nov 2024 17:38:03 +0100 Subject: [PATCH] added check for previous state --- .../public/js/scripts/admin.distraction.free.mode.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js b/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js index 7b0e72fcc4..602ff2977a 100644 --- a/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js +++ b/src/bundle/Resources/public/js/scripts/admin.distraction.free.mode.js @@ -1,6 +1,7 @@ (function (global, doc) { let activeFieldEdit = null; let clearedPositionNodesData = []; + let previousDistractionFreeModeActive = null; const DISTRACTION_FREE_MODE_ENABLE_EVENT_NAME = 'ibexa-distraction-free:enable'; const DISTRACTION_FREE_DISABLE_EVENT_NAME = 'ibexa-distraction-free:disable'; const distractionFreeModeEnableBtns = doc.querySelectorAll('.ibexa-field-edit__distraction-free-mode-control-btn--enable'); @@ -43,10 +44,12 @@ clearedPositionNodesData = []; } const changeDistractionFreeModeState = (active) => { - if (!activeFieldEdit) { + if (!activeFieldEdit || previousDistractionFreeModeActive === active) { return; } + previousDistractionFreeModeActive = active; + const dispatchEventName = active ? DISTRACTION_FREE_MODE_ENABLE_EVENT_NAME : DISTRACTION_FREE_DISABLE_EVENT_NAME; const editorSourceElement = activeFieldEdit.querySelector('.ibexa-data-source__richtext'); const editorInstance = editorSourceElement.ckeditorInstance;