@samitouri / QOS-React-2 / commits / a97b5c07b0

[Flare] More fixes for getAbsoluteBoundingClientRect (#15746)

Dominic Gannaway committed May 27, 2019 at 19:03 UTC a97b5c07b033e0c7f5be5618bb2fdebc03262a55
2 files changed +12 -7
packages/react-events/src/Press.js
+11 -6
@@ -459,12 +459,17 @@ function getAbsoluteBoundingClientRect(
459 // are fixed position, using offsetParent node for a fast-path.
460 // We need to check both as offsetParent accounts for both
461 // itself and the parent; so we need to align with that API.
462 - // If these all pass, we can stop traversing the tree.
463 - if (
464 - (scrollLeft !== 0 || scrollTop !== 0) &&
465 - (isNodeFixedPositioned(parent) || isNodeFixedPositioned(node))
466 - ) {
467 - break;
462 + // If these all pass, we can skip traversing the relevant
463 + // node and go directly to its parent.
464 + if (scrollLeft !== 0 || scrollTop !== 0) {
465 + if (isNodeFixedPositioned(parent)) {
466 + node = ((parent: any): Node).parentNode;
467 + continue;
468 + }
469 + if (isNodeFixedPositioned(node)) {
470 + node = parent;
471 + continue;
472 + }
473 }
474 offsetX += scrollLeft;
475 offsetY += scrollTop;
packages/react-events/src/__tests__/Press-test.internal.js
+1 -1
@@ -1232,7 +1232,7 @@ describe('Event responder: Press', () => {
1232 document.firstElementChild.scrollTop = 1000;
1233 const updatedCoordinatesInside = {
1234 pageX: coordinatesInside.pageX,
1235 - pageY: coordinatesInside.pageY + 100,
1235 + pageY: coordinatesInside.pageY + 1100,
1236 };
1237 ref.current.dispatchEvent(
1238 createEvent('pointerdown', updatedCoordinatesInside),