From 313d485ad104cfa09e3c9a6fdbd11990abc9ee3e Mon Sep 17 00:00:00 2001 From: LeandroTorresSicilia Date: Mon, 31 Oct 2022 12:45:33 -0700 Subject: [PATCH] fix: make picklist responsive for mobile when search is enabled --- src/components/Picklist/index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/Picklist/index.js b/src/components/Picklist/index.js index 2364d4c9d..6b41b3b57 100644 --- a/src/components/Picklist/index.js +++ b/src/components/Picklist/index.js @@ -20,7 +20,7 @@ import InternalDropdown from '../InternalDropdown'; import InternalOverlay from '../InternalOverlay'; import WindowResize from '../../libs/WindowResize'; -function positionResolver(opts) { +function positionResolver(opts, enableSearch) { const { trigger, viewport, content } = opts; const newOpts = { trigger, @@ -30,6 +30,13 @@ function positionResolver(opts) { width: trigger.width, }, }; + if (enableSearch && viewport.width <= 600) { + return { + top: 0, + left: 0, + width: viewport.width, + }; + } return { ...InternalOverlay.defaultPositionResolver(newOpts), width: trigger.width, @@ -82,7 +89,9 @@ class Picklist extends Component { this.handleBlur(); } }); - this.windowScrolling.startListening(this.handleWindowScroll); + if (window.screen.width > 600) { + this.windowScrolling.startListening(this.handleWindowScroll); + } this.windowResize.startListening(this.handleWindowResize); } } @@ -298,9 +307,10 @@ class Picklist extends Component { /> positionResolver(opt, enableSearch)} onOpened={() => this.dropdownRef.current.focus()} triggerElementRef={() => this.triggerRef} + keepScrollEnabled >