Skip to content

Commit

Permalink
Do not toggle edit mode with escape key during IME composition (#7024)
Browse files Browse the repository at this point in the history
Co-authored-by: Natsu Ozawa <nozawa@palantir.com>
  • Loading branch information
natsuozawa and Natsu Ozawa authored Oct 30, 2024
1 parent 1baee86 commit bee98b2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/components/editable-text/editableText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,19 @@ export class EditableText extends AbstractPureComponent<EditableTextProps, Edita
};

private handleKeyEvent = (event: React.KeyboardEvent<HTMLElement>) => {
// During IME composition, Enter and Escape has special meanings that we will not override
if (event.nativeEvent.isComposing) {
return;
}

const { altKey, ctrlKey, metaKey, shiftKey } = event;
if (event.key === "Escape") {
this.cancelEditing();
return;
}

const hasModifierKey = altKey || ctrlKey || metaKey || shiftKey;
if (event.key === "Enter" && !event.nativeEvent.isComposing) {
if (event.key === "Enter") {
// prevent browsers (Edge?) from full screening with alt + enter
// shift + enter adds a newline by default
if (altKey || shiftKey) {
Expand Down

1 comment on commit bee98b2

@svc-palantir-github
Copy link

Choose a reason for hiding this comment

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

Do not toggle edit mode with escape key during IME composition (#7024)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.