Skip to content

Commit

Permalink
Merge pull request #4893 from thematters/fix/editor-input
Browse files Browse the repository at this point in the history
fix(editor): skip enter keydown handler on composing
  • Loading branch information
gitwoz authored Oct 15, 2024
2 parents c07352e + 07a2bc6 commit 7866a1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/Editor/Article/Summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ const EditorSummary: React.FC<Props> = ({
const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
const target = event.target as HTMLTextAreaElement

if (event.key.toLowerCase() === KEYVALUE.enter) {
if (
event.key.toLowerCase() === KEYVALUE.enter &&
!event.nativeEvent.isComposing
) {
event.preventDefault()

if (target.selectionStart === target.value.length) {
Expand Down
5 changes: 4 additions & 1 deletion src/components/Editor/Article/Title/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ const EditorTitle: React.FC<Props> = ({ defaultValue = '', update }) => {
const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
const target = event.target as HTMLTextAreaElement

if (event.key.toLowerCase() === KEYVALUE.enter) {
if (
event.key.toLowerCase() === KEYVALUE.enter &&
!event.nativeEvent.isComposing
) {
event.preventDefault()

if (target.selectionStart === target.value.length) {
Expand Down

0 comments on commit 7866a1d

Please sign in to comment.