Skip to content

Commit

Permalink
fix: chinese input double in qq browser (#4452)
Browse files Browse the repository at this point in the history
* fix: chinese input double in qq browser

* add changeset

* update changeset
  • Loading branch information
dylans authored Aug 13, 2021
1 parent 834ce34 commit 935b3a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/flat-carpets-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': patch
---

double ime fix for qq browser
9 changes: 8 additions & 1 deletion packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
IS_CHROME,
IS_FIREFOX,
IS_FIREFOX_LEGACY,
IS_QQBROWSER,
IS_SAFARI,
} from '../utils/environment'
import { ReactEditor } from '..'
Expand Down Expand Up @@ -714,7 +715,13 @@ export const Editable = (props: EditableProps) => {
// aren't correct and never fire the "insertFromComposition"
// type that we need. So instead, insert whenever a composition
// ends since it will already have been committed to the DOM.
if (!IS_SAFARI && !IS_FIREFOX_LEGACY && !IS_IOS && event.data) {
if (
!IS_SAFARI &&
!IS_FIREFOX_LEGACY &&
!IS_IOS &&
!IS_QQBROWSER &&
event.data
) {
Editor.insertText(editor, event.data)
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/slate-react/src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const IS_FIREFOX_LEGACY =
navigator.userAgent
)

// qq browser
export const IS_QQBROWSER =
typeof navigator !== 'undefined' && /.*QQBrowser/.test(navigator.userAgent)

// Check if DOM is available as React does internally.
// https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
export const CAN_USE_DOM = !!(
Expand Down

0 comments on commit 935b3a7

Please sign in to comment.