Skip to content

Commit

Permalink
added check for previous state
Browse files Browse the repository at this point in the history
  • Loading branch information
GrabowskiM committed Nov 27, 2024
1 parent c1df592 commit 7960cde
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7960cde

Please sign in to comment.