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
18 changes: 13 additions & 5 deletions src/scripts/modules/Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,10 @@ const Selection = Module({
getSelectionBounds () {
const currentRange = this.getCurrentRange();
const rangeRects = currentRange ? currentRange.getClientRects() : [];
const rangeBoundingClientRect = currentRange ? currentRange.getBoundingClientRect() : null;
// NB: This seems to be unnecessary. It's used later for logic that is causing incorrect toolbar alignment.
// Have commented out in case this is actually required for something else.
// - Fred
// const rangeBoundingClientRect = currentRange ? currentRange.getBoundingClientRect() : null;

let selectionBounds = {
top: null,
Expand Down Expand Up @@ -536,10 +539,15 @@ const Selection = Module({
};

const setInitialBoundary = function (rangeRect) {
if (rangeBoundingClientRect) {
selectionBounds.initialLeft = rangeBoundingClientRect.left;
selectionBounds.initialWidth = rangeBoundingClientRect.width;
} else if (rangeRect.top === selectionBounds.top) {
// NB: I have commented this out because it is causing inaccurate toolbar alignment.
// I am leaving it here for now in case it was actually meant for something that I
// can't recall right now.
// - Fred
// if (rangeBoundingClientRect) {
// selectionBounds.initialLeft = rangeBoundingClientRect.left;
// selectionBounds.initialWidth = rangeBoundingClientRect.width;
// } else
if (rangeRect.top === selectionBounds.top) {
if (selectionBounds.initialLeft === null) {
selectionBounds.initialLeft = rangeRect.left;
} else {
Expand Down