diff --git a/src/components/block/index.ts b/src/components/block/index.ts index 8bed7fce..f4cb5a4f 100644 --- a/src/components/block/index.ts +++ b/src/components/block/index.ts @@ -204,8 +204,17 @@ export default class Block extends EventsDispatcher { * Is fired when DOM mutation has been happened */ private didMutated = _.debounce((mutationsOrInputEvent: MutationRecord[] | InputEvent = []): void => { + /** + * We won't fire a Block mutation event for nodes that contain 'data-mutation-free' attributes + * + * Update from 2023, Feb 17: + * Changed mutationsOrInputEvent.some() to mutationsOrInputEvent.every() + * since there could be a real mutations same-time with mutation-free changes, + * for example when Block Tune change: block is changing along with FakeCursor (mutation-free) removing + * — we should fire 'didMutated' event in that case + */ const shouldFireUpdate = mutationsOrInputEvent instanceof InputEvent || - !mutationsOrInputEvent.some(({ + !mutationsOrInputEvent.every(({ addedNodes = [], removedNodes, }) => { diff --git a/test/cypress/tests/onchange.spec.ts b/test/cypress/tests/onchange.spec.ts index 77d46ab0..9b8a0262 100644 --- a/test/cypress/tests/onchange.spec.ts +++ b/test/cypress/tests/onchange.spec.ts @@ -221,14 +221,7 @@ describe('onChange callback', () => { .click(); cy.get('[data-cy=editorjs]') - .get('span.cdx-settings-button[data-level=4]') - .click() - /** - * For some reason, the first click fires the mutation of removeFakeCursor only, so we need to click again. - * Reproduced only in Cypress. - * - * @todo debug it later - */ + .get('.ce-settings .ce-popover-item:nth-child(4)') .click(); cy.get('@onChange').should('be.calledWithMatch', EditorJSApiMock, Cypress.sinon.match({