Skip to content

Commit

Permalink
Fix positioning bug when point value is zero (microsoft#30296)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahgodbolt authored Jan 12, 2024
1 parent 50176a6 commit ca4ebf9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: positioning properly tests if point is at the zero location, instead of returning false",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
9 changes: 4 additions & 5 deletions packages/react/src/utilities/positioning/positioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,6 @@ function _positionBeak(beakWidth: number, elementPosition: IElementPositionInfo)
} else if (!_isEdgeInBounds(beakPosition, elementBounds, negativeEdge)) {
beakPosition = _alignEdges(beakPosition, elementBounds, negativeEdge);
}

return beakPosition;
}

Expand Down Expand Up @@ -995,11 +994,11 @@ function _getRectangleFromTarget(target: Element | MouseEvent | Point | Rectangl
let targetRect: Rectangle;

// eslint-disable-next-line deprecation/deprecation
const left = rectOrPointTarget.left || rectOrPointTarget.x;
const left = rectOrPointTarget.left ?? rectOrPointTarget.x;
// eslint-disable-next-line deprecation/deprecation
const top = rectOrPointTarget.top || rectOrPointTarget.y;
const right = rectOrPointTarget.right || left;
const bottom = rectOrPointTarget.bottom || top;
const top = rectOrPointTarget.top ?? rectOrPointTarget.y;
const right = rectOrPointTarget.right ?? left;
const bottom = rectOrPointTarget.bottom ?? top;

// eslint-disable-next-line no-extra-boolean-cast -- may not actually be a MouseEvent
if (!!mouseTarget.stopPropagation) {
Expand Down

0 comments on commit ca4ebf9

Please sign in to comment.