1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 05:31:56 +02:00

fix blur not triggering (#1342)

This commit is contained in:
Yifeng Wang
2017-10-30 13:18:18 -05:00
committed by Ian Storm Taylor
parent 5973bb41a7
commit d1ee4dba57

View File

@@ -71,27 +71,26 @@ function BeforePlugin() {
const { value } = change const { value } = change
const focusTarget = event.relatedTarget const focusTarget = event.relatedTarget
// If focusTarget is null, the blur event is due to the window itself being // focusTarget may be null when window itself being blurred
// blurred (eg. when changing tabs) so we should ignore the event, since we // (eg. when changing tabs), or when user clicks on elements
// want to maintain focus when returning. // without`tabindex` attribute.
if (!focusTarget) return true if (focusTarget) {
const el = findDOMNode(editor)
// The event should be ignored if the focus returns to the editor from an
// embedded editable element (eg. an input element inside a void node).
if (focusTarget == el) return true
const el = findDOMNode(editor) // when the focus moved from the editor to a void node spacer...
if (focusTarget.hasAttribute('data-slate-spacer')) return true
// The event should also be ignored if the focus returns to the editor from // or to an editable element inside the editor but not into a void node
// an embedded editable element (eg. an input element inside a void node), // (eg. a list item of the check list example).
if (focusTarget == el) return true if (
el.contains(focusTarget) &&
// when the focus moved from the editor to a void node spacer... !findNode(focusTarget, value).isVoid
if (focusTarget.hasAttribute('data-slate-spacer')) return true ) {
return true
// or to an editable element inside the editor but not into a void node }
// (eg. a list item of the check list example).
if (
el.contains(focusTarget) &&
!findNode(focusTarget, value).isVoid
) {
return true
} }
debug('onBlur', { event }) debug('onBlur', { event })