Skip to content

Commit fb53837

Browse files
authored
Merge pull request #34 from typecode/issue-31
#31 - Toolbar alignment refinement
2 parents 7d74c74 + 594b9ba commit fb53837

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/scripts/modules/Selection.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,10 @@ const Selection = Module({
507507
getSelectionBounds () {
508508
const currentRange = this.getCurrentRange();
509509
const rangeRects = currentRange ? currentRange.getClientRects() : [];
510-
const rangeBoundingClientRect = currentRange ? currentRange.getBoundingClientRect() : null;
510+
// NB: This seems to be unnecessary. It's used later for logic that is causing incorrect toolbar alignment.
511+
// Have commented out in case this is actually required for something else.
512+
// - Fred
513+
// const rangeBoundingClientRect = currentRange ? currentRange.getBoundingClientRect() : null;
511514

512515
let selectionBounds = {
513516
top: null,
@@ -542,10 +545,15 @@ const Selection = Module({
542545
};
543546

544547
const setInitialBoundary = function (rangeRect) {
545-
if (rangeBoundingClientRect) {
546-
selectionBounds.initialLeft = rangeBoundingClientRect.left;
547-
selectionBounds.initialWidth = rangeBoundingClientRect.width;
548-
} else if (rangeRect.top === selectionBounds.top) {
548+
// NB: I have commented this out because it is causing inaccurate toolbar alignment.
549+
// I am leaving it here for now in case it was actually meant for something that I
550+
// can't recall right now.
551+
// - Fred
552+
// if (rangeBoundingClientRect) {
553+
// selectionBounds.initialLeft = rangeBoundingClientRect.left;
554+
// selectionBounds.initialWidth = rangeBoundingClientRect.width;
555+
// } else
556+
if (rangeRect.top === selectionBounds.top) {
549557
if (selectionBounds.initialLeft === null) {
550558
selectionBounds.initialLeft = rangeRect.left;
551559
} else {

0 commit comments

Comments
 (0)