Skip to content
Discussion options

You must be logged in to vote

The root cause is that toggleMark immediately returns when editor.selection is null [1]. In JSDOM (what React Testing Library uses), ContentEditable selection behavior isn't fully implemented, so clicking the toolbar button fires onClick but the editor has no valid selection — the mark command becomes a no-op, no state changes, no re-render.

Plate's own tests don't test toolbar clicks with RTL for this reason. Instead, marks are tested at the transform level [2]:

const editor = createSlateEditor({
  plugins: [BoldPlugin],
  value: [{ children: [{ text: 'hello' }] }],
  selection: {
    anchor: { path: [0, 0], offset: 0 },
    focus: { path: [0, 0], offset: 5 },
  },
});

editor.tf.toggle…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@filippodev-tech
Comment options

Answer selected by filippodev-tech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant