diff --git a/packages/slate-react/src/constants/environment.js b/packages/slate-react/src/constants/environment.js index 7fb075aa3..3c4c23e90 100644 --- a/packages/slate-react/src/constants/environment.js +++ b/packages/slate-react/src/constants/environment.js @@ -76,5 +76,6 @@ export const IS_FIREFOX = BROWSER === 'firefox' export const IS_SAFARI = BROWSER === 'safari' export const IS_IE = BROWSER === 'ie' +export const IS_IOS = OS === 'ios' export const IS_MAC = OS === 'macos' export const IS_WINDOWS = OS === 'windows' diff --git a/packages/slate-react/src/plugins/core.js b/packages/slate-react/src/plugins/core.js index b04b09564..53462fa5c 100644 --- a/packages/slate-react/src/plugins/core.js +++ b/packages/slate-react/src/plugins/core.js @@ -10,7 +10,7 @@ import Content from '../components/content' import Placeholder from '../components/placeholder' import findDOMNode from '../utils/find-dom-node' import findRange from '../utils/find-range' -import { IS_CHROME, IS_MAC, IS_SAFARI } from '../constants/environment' +import { IS_CHROME, IS_IOS, IS_MAC, IS_SAFARI } from '../constants/environment' /** * Debug. @@ -77,14 +77,16 @@ function Plugin(options = {}) { // selection will be changed to span the existing word, so that the word is // replaced. But the `select` fires after the `beforeInput` event, even // though the native selection is updated. So we need to manually check if - // the selection has gotten out of sync, and adjust it if so. (03/18/2017) - const window = getWindow(e.target) - const native = window.getSelection() - const range = findRange(native, state) - const hasMismatch = range && !range.equals(selection) + // the selection has gotten out of sync, and adjust it if so. (10/16/2017) + if (IS_IOS) { + const window = getWindow(e.target) + const native = window.getSelection() + const range = findRange(native, state) + const hasMismatch = range && !range.equals(selection) - if (hasMismatch) { - change.select(range) + if (hasMismatch) { + change.select(range) + } } change.insertText(e.data)