Skip to content

fix(link): guard IME composition-commit Enter (keyCode 229) in floating link#5048

Merged
zbeyens merged 1 commit into
udecode:mainfrom
greymoth-jp:fix/floating-link-ime-enter-229
Jun 30, 2026
Merged

fix(link): guard IME composition-commit Enter (keyCode 229) in floating link#5048
zbeyens merged 1 commit into
udecode:mainfrom
greymoth-jp:fix/floating-link-ime-enter-229

Conversation

@greymoth-jp

@greymoth-jp greymoth-jp commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • Auto release

Problem

useFloatingLinkEnter submits the floating link on any keydown that reaches the global hotkey handler with e.key === 'Enter':

if (e.key !== 'Enter') return;
if (submitFloatingLink(editor)) {
  e.preventDefault();
}

On Safari/WebKit with a Japanese IME, the keydown that commits a composition arrives with e.key === 'Enter', e.keyCode === 229, and e.isComposing === false. So when a user types a CJK link label and presses Enter to confirm the composition, this handler treats it as a submit and closes the floating link mid-composition.

Fix

Skip the IME composition-commit Enter, the same way the rest of the repo already does:

  • packages/udecode/cmdk/src/cmdk.tsx: if (!e.nativeEvent.isComposing && e.keyCode !== 229), with a comment that isComposing is not set for the Japanese IME + Safari combination.
  • packages/table/src/react/onKeyDownTable.ts: const compositeKeyCode = 229; ... event.which === compositeKeyCode.
if (e.key !== 'Enter') return;
if (e.isComposing || e.keyCode === 229) return;

A normal Enter (keyCode === 13, isComposing === false) still submits.

Notes

The vendored react-hotkeys matches by event.code, which is still 'Enter' on the IME-commit key, so the callback is where the guard belongs. I kept it at the call site to match the existing cmdk/table guards instead of touching the fork.

keyCode is not reproducible in jsdom (it reads as 0), so I verified this by the same logic as the existing guards rather than a unit test, which is also why those guards have none.

@greymoth-jp greymoth-jp requested a review from a team June 30, 2026 06:46
@codesandbox

codesandbox Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b4c8eaf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@platejs/link Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. ime patch Bugfix & documentation PR plugin:link labels Jun 30, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 30, 2026
@zbeyens zbeyens merged commit df0996f into udecode:main Jun 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ime lgtm This PR has been approved by a maintainer patch Bugfix & documentation PR plugin:link size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants