Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15266 from atom/ns-fix-alt-bindings-on-mac
Browse files Browse the repository at this point in the history
Suppress composition events default prevented on previous keydown
  • Loading branch information
Nathan Sobo committed Aug 12, 2017
1 parent 0f45a1c commit 52f49ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/text-editor-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,10 @@ class TextEditorComponent {
}

didTextInput (event) {
// Workaround for Chromium not preventing composition events when
// preventDefault is called on the keydown event that precipitated them.
if (this.lastKeydown && this.lastKeydown.defaultPrevented) return

if (!this.isInputEnabled()) return

event.stopPropagation()
Expand Down Expand Up @@ -1626,7 +1630,6 @@ class TextEditorComponent {

didKeypress (event) {
this.lastKeydownBeforeKeypress = this.lastKeydown
this.lastKeydown = null

// This cancels the accented character behavior if we type a key normally
// with the menu open.
Expand All @@ -1636,7 +1639,6 @@ class TextEditorComponent {
didKeyup (event) {
if (this.lastKeydownBeforeKeypress && this.lastKeydownBeforeKeypress.code === event.code) {
this.lastKeydownBeforeKeypress = null
this.lastKeydown = null
}
}

Expand All @@ -1662,6 +1664,10 @@ class TextEditorComponent {
}

didCompositionUpdate (event) {
// Workaround for Chromium not preventing composition events when
// preventDefault is called on the keydown event that precipitated them.
if (this.lastKeydown && this.lastKeydown.defaultPrevented) return

if (this.getChromeVersion() === 56) {
process.nextTick(() => {
if (this.compositionCheckpoint) {
Expand Down

0 comments on commit 52f49ab

Please sign in to comment.