Skip to content

fix(paste): do not select blocks when rendering HTML in read-only mode - #3063

Open
Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2869-render-from-html-selected-class
Open

Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2869-render-from-html-selected-class

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Summary

Closes #2869.

In read-only mode, renderFromHTML marked the last rendered block as selected. Blocks created in read-only mode are not focusable, so Caret.setToBlock falls back to BlockSelection.selectBlock, which adds the ce-block--selected class. Rendering content programmatically should not select anything.

Changes

  • Skip caret placement in Paste.insertBlock and Paste.processText when the editor is read-only
  • Add regression tests for single and multiple blocks rendered via renderFromHTML in read-only mode

Testing

  • yarn lint
  • npx cypress run --spec test/cypress/tests/api/blocks.cy.ts
  • npx cypress run --spec test/cypress/tests/readOnly.cy.ts
  • npx cypress run --spec test/cypress/tests/copy-paste.cy.ts

Both new tests fail without the change and pass with it. Verified the same behaviour on 2.30.7 before the fix.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blocks.renderFromHTML always added class name 'ce-block--selected' for latest block

1 participant