Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/renderers/dom/shared/ReactInputSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,27 @@ var ReactInputSelection = {
priorSelectionRange
);
}

// Focusing a node can change the scroll position, which is undesirable
const ancestors = [];
let ancestor = priorFocusedElem;
while ((ancestor = ancestor.parentNode)) {
if (ancestor.nodeType === 1) {
ancestors.push({
element: ancestor,
left: ancestor.scrollLeft,
top: ancestor.scrollTop,
});
}
}

focusNode(priorFocusedElem);

for (let i = 0; i < ancestors.length; i++) {
const ancestor = ancestors[i];
ancestor.element.scrollLeft = ancestor.left;
ancestor.element.scrollTop = ancestor.top;
}
}
},

Expand Down