mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-10 17:24:02 +02:00
fix(firefox): fixed the bug that happens when changing the focus from one field to another (#2236)
* fix(firefox): fixed the bug that happens when changing the focus from one field to another
* Publish
- slate-base64-serializer@0.2.69
- slate-html-serializer@0.7.8
- slate-hyperscript@0.10.8
- slate-plain-serializer@0.6.8
- slate-prop-types@0.4.67
- slate-react@0.18.11
- slate-simulator@0.4.67
- slate@0.41.3
* Publish
- slate-base64-serializer@0.2.70
- slate-html-serializer@0.7.9
- slate-hyperscript@0.10.9
- slate-plain-serializer@0.6.9
- slate-prop-types@0.4.68
- slate-react@0.18.12
- slate-simulator@0.4.68
- slate@0.41.4
* Publish
- slate-react@0.18.13
* Revert "Fix an occasional crash in Firefox in isInEditor (#2229)"
This reverts commit 1ff050265b
.
* fix(firefox): added postinstall script to the main project
* fix(firefox): removed error causing line
* fix(firefox): added the right fix for this
* fix(firefox): added the best fix for this
* fix(firefox): made the range a constant
* fix(firefox): added the removeAllRanges inside the if wrapper
* fix(lint): fixed lint error
* fix(versions): removed changes for the package.json files
* fix(versions): removed remaining changes for the package.json files
* fix(conflict): fixed the issue that resolving the conflicts caused last time
* fix(lint): fixed the last lint error
* chore(content): moved comment in setTimeout to see why git is not showing conflicts locally
This commit is contained in:
committed by
Ian Storm Taylor
parent
5c4e4f9548
commit
6aba4260f8
@@ -286,43 +286,39 @@ class Content extends React.Component {
|
|||||||
// Otherwise, set the `isUpdatingSelection` flag and update the selection.
|
// Otherwise, set the `isUpdatingSelection` flag and update the selection.
|
||||||
updated = true
|
updated = true
|
||||||
this.tmp.isUpdatingSelection = true
|
this.tmp.isUpdatingSelection = true
|
||||||
removeAllRanges(native)
|
|
||||||
|
|
||||||
// COMPAT: IE 11 does not support `setBaseAndExtent`. (2018/11/07)
|
if (!IS_FIREFOX) {
|
||||||
if (native.setBaseAndExtent) {
|
removeAllRanges(native)
|
||||||
// COMPAT: Since the DOM range has no concept of backwards/forwards
|
|
||||||
// we need to check and do the right thing here.
|
// COMPAT: IE 11 does not support `setBaseAndExtent`. (2018/11/07)
|
||||||
if (isBackward) {
|
if (native.setBaseAndExtent) {
|
||||||
native.setBaseAndExtent(
|
// COMPAT: Since the DOM range has no concept of backwards/forwards
|
||||||
range.endContainer,
|
// we need to check and do the right thing here.
|
||||||
range.endOffset,
|
if (isBackward) {
|
||||||
range.startContainer,
|
native.setBaseAndExtent(
|
||||||
range.startOffset
|
range.endContainer,
|
||||||
)
|
range.endOffset,
|
||||||
|
range.startContainer,
|
||||||
|
range.startOffset
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
native.setBaseAndExtent(
|
||||||
|
range.startContainer,
|
||||||
|
range.startOffset,
|
||||||
|
range.endContainer,
|
||||||
|
range.endOffset
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
native.setBaseAndExtent(
|
native.addRange(range)
|
||||||
range.startContainer,
|
|
||||||
range.startOffset,
|
|
||||||
range.endContainer,
|
|
||||||
range.endOffset
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
native.addRange(range)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll to the selection, in case it's out of view.
|
// Scroll to the selection, in case it's out of view.
|
||||||
scrollToSelection(native)
|
scrollToSelection(native)
|
||||||
|
|
||||||
// Then unset the `isUpdatingSelection` flag after a delay, to ensure that
|
// Then unset the `isUpdatingSelection` flag after a delay.
|
||||||
// it is still set when selection-related events from updating it fire.
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// COMPAT: In Firefox, it's not enough to create a range, you also need
|
|
||||||
// to focus the contenteditable element too. (2016/11/16)
|
|
||||||
if (IS_FIREFOX && this.ref.current) {
|
|
||||||
this.ref.current.focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
this.tmp.isUpdatingSelection = false
|
this.tmp.isUpdatingSelection = false
|
||||||
|
|
||||||
debug.update('updateSelection:setTimeout', {
|
debug.update('updateSelection:setTimeout', {
|
||||||
@@ -357,12 +353,6 @@ class Content extends React.Component {
|
|||||||
let el
|
let el
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// COMPAT: In Firefox, sometimes the node can be comment which doesn't
|
|
||||||
// have .closest and it crashes.
|
|
||||||
if (target.nodeType === 8) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// COMPAT: Text nodes don't have `isContentEditable` property. So, when
|
// COMPAT: Text nodes don't have `isContentEditable` property. So, when
|
||||||
// `target` is a text node use its parent node for check.
|
// `target` is a text node use its parent node for check.
|
||||||
el = target.nodeType === 3 ? target.parentNode : target
|
el = target.nodeType === 3 ? target.parentNode : target
|
||||||
|
Reference in New Issue
Block a user