Skip to content

fix: prevent form submission during input composition - #1423

Open
makhnatkin wants to merge 2 commits into
mainfrom
test/forms-before-uikit8
Open

makhnatkin wants to merge 2 commits into
mainfrom
test/forms-before-uikit8

Conversation

@makhnatkin

Copy link
Copy Markdown
Collaborator

Attachment form submission

  • Added regression coverage for file and image submission after input composition.
  • Updated text fields to submit on Enter keydown.
  • Prevented Enter from submitting during input composition.

@makhnatkin
makhnatkin requested a review from d3m1d0v as a code owner November 6, 2026 17:41

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/editor/src/utils/handlers.ts" line_range="7" />
<code_context>
 ): React.KeyboardEventHandler<T> {
     return (event) => {
-        if (event.key === Key.Enter) {
+        if (event.key === Key.Enter && !event.nativeEvent.isComposing) {
             handler(event);
         }
</code_context>
<issue_to_address>
**Form submits during IME composition**

When a browser reports `isComposing` as false on the Enter keydown that confirms composition, `enterKeyHandler` calls the submit handler for that Enter keydown, so the form submits before the composed text is finished.

Also treat `keyCode === 229` as composition input and skip calling the handler for that Enter keydown.

Also at `packages/editor/src/forms/FileForm.tsx:111`, `packages/editor/src/forms/ImageForm.tsx:121`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread packages/editor/src/utils/handlers.ts Resolved
@gravity-ui

gravity-ui Bot commented Nov 6, 2026

Copy link
Copy Markdown

Storybook Deployed

@gravity-ui

gravity-ui Bot commented Nov 6, 2026

Copy link
Copy Markdown

🎭 Playwright Report

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.

1 participant