1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 16:10:26 +00:00

fix-selection-bug

Fix draft selection bug when users select side panel.
This commit is contained in:
Michael18811380328
2018-12-26 14:51:44 +08:00
parent b4060007ad
commit 2934a3b2a1

View File

@@ -222,6 +222,9 @@ class DraftReview extends React.Component {
// fix select last paragraph
let fragment = nativeRange.cloneContents();
let startNode = fragment.firstChild.firstChild;
if (!startNode) {
return;
}
let newNativeRange = document.createRange();
newNativeRange.setStartBefore(startNode);
newNativeRange.setEndAfter(startNode);
@@ -230,6 +233,9 @@ class DraftReview extends React.Component {
else {
this.range = findRange(nativeRange, this.refs.diffViewer.value);
}
if (!this.range) {
return;
}
let rect = nativeRange.getBoundingClientRect();
// fix Safari bug
if (navigator.userAgent.indexOf('Chrome') < 0 && navigator.userAgent.indexOf('Safari') > 0) {