From 1cc5497ffc7f5aff68e7324d5344eab7a6bac759 Mon Sep 17 00:00:00 2001 From: emyarod Date: Fri, 20 Nov 2020 10:02:43 -0600 Subject: [PATCH 1/3] refactor(FloatingMenu): remove else-if-return --- packages/react/src/internal/FloatingMenu.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/react/src/internal/FloatingMenu.js b/packages/react/src/internal/FloatingMenu.js index 09863daedb6e..9b707ec881f0 100644 --- a/packages/react/src/internal/FloatingMenu.js +++ b/packages/react/src/internal/FloatingMenu.js @@ -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 From b29724facae1ab410ac75fe6af5ef36cca19f343 Mon Sep 17 00:00:00 2001 From: emyarod Date: Fri, 20 Nov 2020 10:06:08 -0600 Subject: [PATCH 2/3] fix(FloatingMenu): ignore scroll offset in sticky container --- packages/react/src/internal/FloatingMenu.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/react/src/internal/FloatingMenu.js b/packages/react/src/internal/FloatingMenu.js index 9b707ec881f0..90d9655ff3bb 100644 --- a/packages/react/src/internal/FloatingMenu.js +++ b/packages/react/src/internal/FloatingMenu.js @@ -88,8 +88,8 @@ const getFloatingPosition = ({ refPosition = {}, offset = {}, direction = DIRECTION_BOTTOM, - scrollX = 0, - scrollY = 0, + scrollX: pageXOffset = 0, + scrollY: pageYOffset = 0, container, }) => { const { @@ -98,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 === 'sticky' ? 0 : pageXOffset; + const scrollY = container.position === 'sticky' ? 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; From 723eb8219b680d20054e97c53c085bdf3ee2735e Mon Sep 17 00:00:00 2001 From: emyarod Date: Mon, 30 Nov 2020 11:09:12 -0600 Subject: [PATCH 3/3] refactor(FloatingMenu): ignore scroll position for non static elements --- packages/react/src/internal/FloatingMenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react/src/internal/FloatingMenu.js b/packages/react/src/internal/FloatingMenu.js index 90d9655ff3bb..2c2cfa436b36 100644 --- a/packages/react/src/internal/FloatingMenu.js +++ b/packages/react/src/internal/FloatingMenu.js @@ -98,8 +98,8 @@ const getFloatingPosition = ({ right: refRight = 0, bottom: refBottom = 0, } = refPosition; - const scrollX = container.position === 'sticky' ? 0 : pageXOffset; - const scrollY = container.position === 'sticky' ? 0 : pageYOffset; + 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,