Skip to content

fix: do not cancel CodeMirror compose beforeChange - #328

Open
Steve0x2a wants to merge 1 commit into
scniro:masterfrom
Steve0x2a:fix/compose-beforechange
Open

fix: do not cancel CodeMirror compose beforeChange#328
Steve0x2a wants to merge 1 commit into
scniro:masterfrom
Steve0x2a:fix/compose-beforechange

Conversation

@Steve0x2a

Copy link
Copy Markdown

Controlled beforeChange currently calls data.cancel() for every origin, including CodeMirror 5 IME/dead-key changes (origin === "*compose"). Cancelling those prevents composition from committing (' + eé, macOS double-space → period). The UnControlled wrapper does not cancel.

This skips data.cancel() when data.origin === "*compose", still notifies onBeforeChange, and avoids replaying the change with setValue/replaceRange while the native compose change is in flight. Undo/redo and the emulating path are unchanged.

Credits @mblagojevic10 for the report and the *compose diagnosis.

Fixes #327

Test plan

  • New unit: Controlled beforeChange with origin: "*compose" is not cancelled, and the composed character is applied
  • New unit: updating value from onBeforeChange during compose does not duplicate the character
  • Existing suite (npm test): 46 passed

Signed-off-by: Yi Zhan <stevesough@gmail.com>
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.

Bug report: IME/dead-key composition broken in Controlled wrapper (react-codemirror2 v9.0.1 + CodeMirror 5.65.20 + React 18)

1 participant