Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FloatingMenu): ignore extra scroll offset in sticky container #7323

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
27 changes: 10 additions & 17 deletions packages/react/src/internal/FloatingMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ export const DIRECTION_BOTTOM = 'bottom';
const hasChangeInOffset = (oldMenuOffset = {}, menuOffset = {}) => {
if (typeof oldMenuOffset !== typeof menuOffset) {
return true;
} else if (
Object(menuOffset) === menuOffset &&
typeof menuOffset !== 'function'
) {
}
if (Object(menuOffset) === menuOffset && typeof menuOffset !== 'function') {
return (
oldMenuOffset.top !== menuOffset.top ||
oldMenuOffset.left !== menuOffset.left
Expand All @@ -90,8 +88,8 @@ const getFloatingPosition = ({
refPosition = {},
offset = {},
direction = DIRECTION_BOTTOM,
scrollX = 0,
scrollY = 0,
scrollX: pageXOffset = 0,
scrollY: pageYOffset = 0,
container,
}) => {
const {
Expand All @@ -100,17 +98,12 @@ const getFloatingPosition = ({
right: refRight = 0,
bottom: refBottom = 0,
} = refPosition;
const relativeDiff =
container.position !== 'static'
? {
top: container.rect.top,
left: container.rect.left,
}
: {
top: 0,
left: 0,
};

const scrollX = container.position !== 'static' ? 0 : pageXOffset;
const scrollY = container.position !== 'static' ? 0 : pageYOffset;
const relativeDiff = {
top: container.position !== 'static' ? container.rect.top : 0,
left: container.position !== 'static' ? container.rect.left : 0,
};
const { width, height } = menuSize;
const { top = 0, left = 0 } = offset;
const refCenterHorizontal = (refLeft + refRight) / 2;
Expand Down