1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-15 03:33:59 +02:00

Fix several undo/redo issues related to selection operation (#2948)

Should fix the following issues: #2891, #2729
This commit is contained in:
Stan Gurenkov
2019-08-22 11:28:13 -07:00
committed by Ian Storm Taylor
parent 6e56932ee4
commit de376d79b8
2 changed files with 33 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ import {
IS_FIREFOX,
HAS_INPUT_EVENTS_LEVEL_2,
} from 'slate-dev-environment'
import Hotkeys from 'slate-hotkeys'
import EVENT_HANDLERS from '../constants/event-handlers'
import DATA_ATTRS from '../constants/data-attributes'
@@ -386,10 +387,15 @@ class Content extends React.Component {
onEvent(handler, event) {
debug('onEvent', handler)
const nativeEvent = event.nativeEvent || event
const isUndoRedo =
event.type === 'keydown' &&
(Hotkeys.isUndo(nativeEvent) || Hotkeys.isRedo(nativeEvent))
// Ignore `onBlur`, `onFocus` and `onSelect` events generated
// programmatically while updating selection.
if (
this.tmp.isUpdatingSelection &&
(this.tmp.isUpdatingSelection || isUndoRedo) &&
(handler === 'onSelect' || handler === 'onBlur' || handler === 'onFocus')
) {
return