Skip to content

Commit 8fdb394

Browse files
committed
MP-305 - use popper & portals to make the dropdowns in modals overflow the modal body
1 parent 0001bd6 commit 8fdb394

File tree

10 files changed

+92
-121
lines changed

10 files changed

+92
-121
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"@datadog/browser-logs": "^4.21.2",
2525
"@heroicons/react": "^1.0.6",
26+
"@popperjs/core": "^2.11.8",
2627
"@sprig-technologies/sprig-browser": "^2.20.1",
2728
"@storybook/addon-actions": "^7.0.5",
2829
"@storybook/react": "^7.0.5",
@@ -83,6 +84,7 @@
8384
"react-helmet": "^6.1.0",
8485
"react-html-parser": "^2.0.2",
8586
"react-markdown": "8.0.6",
87+
"react-popper": "^2.3.0",
8688
"react-redux": "^8.0.4",
8789
"react-redux-toastr": "^7.6.10",
8890
"react-responsive": "^9.0.0-beta.5",

src/apps/profiles/src/member-profile/languages/ModifyLanguagesModal/ModifyLanguagesModal.module.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,3 @@
5050
}
5151
}
5252
}
53-
54-
.langModal {
55-
@include gtemd {
56-
overflow: visible !important;
57-
}
58-
}
59-
60-
.langModalBody {
61-
overflow: visible !important;
62-
}

src/apps/profiles/src/member-profile/local-info/ModifyLocationModal/ModifyLocationModal.module.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,3 @@
1717
margin-bottom: $sp-4;
1818
}
1919
}
20-
21-
.localModal {
22-
@include gtemd {
23-
overflow: visible !important;
24-
}
25-
}
26-
27-
.localModalBody {
28-
overflow: visible !important;
29-
}

src/apps/profiles/src/member-profile/skills/ModifySkillsModal/ModifySkillsModal.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828

2929
.skillsModalBody {
3030
overflow: visible !important;
31-
}
31+
}

src/apps/profiles/src/member-profile/work-expirence/ModifyWorkExpirenceModal/ModifyWorkExpirenceModal.module.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
align-items: center;
2929
margin-left: $sp-15;
3030

31+
@include ltemd {
32+
margin-left: $sp-4;
33+
}
34+
3135
:global(button) {
3236
padding: $sp-2;
3337
color: $turq-160;
@@ -83,4 +87,4 @@
8387
display: flex;
8488
justify-content: space-between;
8589
width: 100%;
86-
}
90+
}

src/libs/ui/lib/components/form/form-groups/form-input/input-date-picker/InputDatePicker.module.scss

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@import '@libs/ui/styles/includes';
22

3-
.container {
3+
:global(#react-date-portal) {
4+
position: relative;
5+
z-index: 10001;
46
:global(.react-datepicker__header) {
57
background-color: $tc-white;
68
border-bottom: none;
@@ -30,34 +32,36 @@
3032
color: $tc-white;
3133
border-radius: 50%;
3234
}
35+
}
3336

34-
.headerWrap {
35-
display: flex;
36-
justify-content: space-between;
37-
padding: $sp-2 0;
38-
border-bottom: 2px solid $black-5;
37+
.headerWrap {
38+
display: flex;
39+
justify-content: space-between;
40+
padding: $sp-2 0;
41+
border-bottom: 2px solid $black-5;
3942

40-
button {
41-
svg {
42-
width: 27px;
43-
height: 27px;
44-
}
43+
button {
44+
svg {
45+
width: 27px;
46+
height: 27px;
4547
}
48+
}
4649

47-
select {
48-
border: none;
49-
background-color: transparent;
50-
margin: auto;
51-
-webkit-appearance: menulist;
52-
appearance: menulist;
50+
select {
51+
border: none;
52+
background-color: transparent;
53+
margin: auto;
54+
-webkit-appearance: menulist;
55+
appearance: menulist;
5356

54-
option:hover {
55-
background-color: $turq-160;
56-
color: $tc-white;
57-
}
57+
option:hover {
58+
background-color: $turq-160;
59+
color: $tc-white;
5860
}
5961
}
62+
}
6063

64+
.container {
6165
input {
6266
border: none;
6367
pointer-events: none;
@@ -74,4 +78,4 @@
7478
text-transform: none;
7579
}
7680
}
77-
}
81+
}

src/libs/ui/lib/components/form/form-groups/form-input/input-date-picker/InputDatePicker.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ const InputDatePicker: FC<InputDatePickerProps> = (props: InputDatePickerProps)
130130
maxTime={props.maxTime}
131131
showYearPicker={props.showYearPicker}
132132
dateFormat={props.dateFormat}
133+
popperPlacement='bottom'
134+
portalId='react-date-portal'
133135
/>
134136
</InputWrapper>
135137
)

src/libs/ui/lib/components/form/form-groups/form-input/input-select/InputSelect.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
left: 0;
2424
width: 100%;
2525
&:not(:empty) {
26-
z-index: 9;
26+
z-index: 1001;
2727
}
2828
}
2929

src/libs/ui/lib/components/form/form-groups/form-input/input-select/InputSelect.tsx

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ import {
1111
useRef,
1212
useState,
1313
} from 'react'
14+
import { usePopper } from 'react-popper'
1415
import classNames from 'classnames'
1516

17+
import { beforeWrite } from '@popperjs/core/lib'
1618
import { useClickOutside } from '~/libs/shared/lib/hooks'
1719

1820
import { IconOutline } from '../../../../svgs'
1921
import { InputWrapper } from '../input-wrapper'
22+
import { Portal } from '../../../../portal'
2023

2124
import styles from './InputSelect.module.scss'
2225

@@ -40,12 +43,33 @@ interface InputSelectProps {
4043
readonly value?: string
4144
}
4245

46+
const sameWidthModifier = {
47+
effect: ({ state }: any) => {
48+
state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`
49+
},
50+
enabled: true,
51+
fn: ({ state }: any) => {
52+
state.styles.popper.width = `${state.rects.reference.width}px`
53+
return state
54+
},
55+
name: 'sameWidth',
56+
phase: beforeWrite,
57+
requires: ['computeStyles'],
58+
}
59+
const modifiers = [sameWidthModifier]
60+
4361
const InputSelect: FC<InputSelectProps> = (props: InputSelectProps) => {
4462
const triggerRef: MutableRefObject<any> = useRef(undefined)
63+
const popperRef: MutableRefObject<any> = useRef(undefined)
4564
const buttonRef: MutableRefObject<HTMLButtonElement | null> = useRef(null)
4665
const [menuIsVisible, setMenuIsVisible]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
4766
const [isFocus, setIsFocus]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
4867

68+
const popper = usePopper(triggerRef.current?.firstChild, popperRef.current, {
69+
modifiers,
70+
strategy: 'absolute',
71+
})
72+
4973
const selectedOption: InputSelectOption | undefined = props.options.find(option => option.value === props.value)
5074

5175
const label: (option: InputSelectOption) => ReactNode = (option?: InputSelectOption) => (
@@ -125,27 +149,34 @@ const InputSelect: FC<InputSelectProps> = (props: InputSelectProps) => {
125149
</span>
126150
</button>
127151

128-
<div className={styles['menu-wrap']}>
129-
{menuIsVisible && (
130-
<div className={styles['select-menu']}>
131-
{props.options.map(option => (
132-
<div
133-
className={
134-
classNames(
135-
styles['select-option'],
136-
'body-main',
137-
selectedOption === option && 'selected',
138-
)
139-
}
140-
onClick={select(option)}
141-
key={option.value}
142-
>
143-
{label(option)}
144-
</div>
145-
))}
146-
</div>
147-
)}
148-
</div>
152+
<Portal>
153+
<div
154+
className={styles['menu-wrap']}
155+
ref={popperRef}
156+
style={popper.styles.popper}
157+
{...popper.attributes.popper}
158+
>
159+
{menuIsVisible && (
160+
<div className={styles['select-menu']}>
161+
{props.options.map(option => (
162+
<div
163+
className={
164+
classNames(
165+
styles['select-option'],
166+
'body-main',
167+
selectedOption === option && 'selected',
168+
)
169+
}
170+
onClick={select(option)}
171+
key={option.value}
172+
>
173+
{label(option)}
174+
</div>
175+
))}
176+
</div>
177+
)}
178+
</div>
179+
</Portal>
149180

150181
</InputWrapper>
151182
)

yarn.lock

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,13 +1504,6 @@
15041504
dependencies:
15051505
regenerator-runtime "^0.13.11"
15061506

1507-
"@babel/runtime@^7.13.8", "@babel/runtime@^7.6.3":
1508-
version "7.22.6"
1509-
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438"
1510-
integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==
1511-
dependencies:
1512-
regenerator-runtime "^0.13.11"
1513-
15141507
"@babel/runtime@^7.17.8", "@babel/runtime@^7.7.6":
15151508
version "7.21.0"
15161509
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673"
@@ -2728,7 +2721,7 @@
27282721
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1"
27292722
integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==
27302723

2731-
"@popperjs/core@^2.11.6", "@popperjs/core@^2.9.2":
2724+
"@popperjs/core@^2.11.8", "@popperjs/core@^2.9.2":
27322725
version "2.11.8"
27332726
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f"
27342727
integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==
@@ -2738,13 +2731,6 @@
27382731
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.0.5.tgz#d5c65626add4c3c185a89aa5bd38b1e42daec075"
27392732
integrity sha512-my0Mycd+jruq/1lQuO5LBB6WTlL/e8DTCYWp44DfMTDcXz8DcTlgF0ISaLsGewt+ctHN+yA8xMq3q/N7uWJPug==
27402733

2741-
"@restart/hooks@^0.4.7":
2742-
version "0.4.9"
2743-
resolved "https://registry.yarnpkg.com/@restart/hooks/-/hooks-0.4.9.tgz#ad858fb39d99e252cccce19416adc18fc3f18fcb"
2744-
integrity sha512-3BekqcwB6Umeya+16XPooARn4qEPW6vNvwYnlofIYe6h9qG1/VeD7UvShCWx11eFz5ELYmwIEshz+MkPX3wjcQ==
2745-
dependencies:
2746-
dequal "^2.0.2"
2747-
27482734
"@rollup/plugin-babel@^5.2.0":
27492735
version "5.3.1"
27502736
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283"
@@ -4533,15 +4519,6 @@
45334519
"@types/scheduler" "*"
45344520
csstype "^3.0.2"
45354521

4536-
"@types/react@>=16.9.11":
4537-
version "18.2.14"
4538-
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.14.tgz#fa7a6fecf1ce35ca94e74874f70c56ce88f7a127"
4539-
integrity sha512-A0zjq+QN/O0Kpe30hA1GidzyFjatVvrpIvWLxD+xv67Vt91TWWgco9IvrJBkeyHm1trGaFS/FSGqPlhyeZRm0g==
4540-
dependencies:
4541-
"@types/prop-types" "*"
4542-
"@types/scheduler" "*"
4543-
csstype "^3.0.2"
4544-
45454522
"@types/redux-actions@2.6.2":
45464523
version "2.6.2"
45474524
resolved "https://registry.yarnpkg.com/@types/redux-actions/-/redux-actions-2.6.2.tgz#5956d9e7b9a644358e2c0610f47b1fa3060edc21"
@@ -4686,11 +4663,6 @@
46864663
resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.7.10.tgz#f9763dc0933f8324920afa9c0790308eedf55ca7"
46874664
integrity sha512-t1yxFAR2n0+VO6hd/FJ9F2uezAZVWHLmpmlJzm1eX03+H7+HsuTAp7L8QJs+2pQCfWkP1+EXsGK9Z9v7o/qPVQ==
46884665

4689-
"@types/warning@^3.0.0":
4690-
version "3.0.0"
4691-
resolved "https://registry.yarnpkg.com/@types/warning/-/warning-3.0.0.tgz#0d2501268ad8f9962b740d387c4654f5f8e23e52"
4692-
integrity sha512-t/Tvs5qR47OLOr+4E9ckN8AmP2Tf16gWq+/qA4iUGS/OOyHVO8wv2vjJuX8SNOUTJyWb+2t7wJm6cXILFnOROA==
4693-
46944666
"@types/ws@^8.5.1":
46954667
version "8.5.3"
46964668
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d"
@@ -7768,7 +7740,7 @@ dom-converter@^0.2.0:
77687740
dependencies:
77697741
utila "~0.4"
77707742

7771-
dom-helpers@^5.0.1, dom-helpers@^5.2.0:
7743+
dom-helpers@^5.0.1:
77727744
version "5.2.1"
77737745
resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-5.2.1.tgz#d9400536b2bf8225ad98fe052e029451ac40e902"
77747746
integrity sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==
@@ -15381,20 +15353,6 @@ react-only-when@^1.0.2:
1538115353
resolved "https://registry.yarnpkg.com/react-only-when/-/react-only-when-1.0.2.tgz#a8a79b48dd6cfbd91ddc710674a94153e88039d3"
1538215354
integrity sha512-agE6l3L6bqaVuwNtjihTQ36M+VBfPS63KOzcNL4ZTmlwSxQPvhzIqmBWfiol0/wLYmKxCcBqgXkEJpvj5Kob8Q==
1538315355

15384-
react-overlays@^5.2.1:
15385-
version "5.2.1"
15386-
resolved "https://registry.yarnpkg.com/react-overlays/-/react-overlays-5.2.1.tgz#49dc007321adb6784e1f212403f0fb37a74ab86b"
15387-
integrity sha512-GLLSOLWr21CqtJn8geSwQfoJufdt3mfdsnIiQswouuQ2MMPns+ihZklxvsTDKD3cR2tF8ELbi5xUsvqVhR6WvA==
15388-
dependencies:
15389-
"@babel/runtime" "^7.13.8"
15390-
"@popperjs/core" "^2.11.6"
15391-
"@restart/hooks" "^0.4.7"
15392-
"@types/warning" "^3.0.0"
15393-
dom-helpers "^5.2.0"
15394-
prop-types "^15.7.2"
15395-
uncontrollable "^7.2.1"
15396-
warning "^4.0.3"
15397-
1539815356
react-popper@^2.2.5, react-popper@^2.3.0:
1539915357
version "2.3.0"
1540015358
resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-2.3.0.tgz#17891c620e1320dce318bad9fede46a5f71c70ba"
@@ -18046,16 +18004,6 @@ unbox-primitive@^1.0.2:
1804618004
has-symbols "^1.0.3"
1804718005
which-boxed-primitive "^1.0.2"
1804818006

18049-
uncontrollable@^7.2.1:
18050-
version "7.2.1"
18051-
resolved "https://registry.yarnpkg.com/uncontrollable/-/uncontrollable-7.2.1.tgz#1fa70ba0c57a14d5f78905d533cf63916dc75738"
18052-
integrity sha512-svtcfoTADIB0nT9nltgjujTi7BzVmwjZClOmskKu/E8FW9BXzg9os8OLr4f8Dlnk0rYWJIWr4wv9eKUXiQvQwQ==
18053-
dependencies:
18054-
"@babel/runtime" "^7.6.3"
18055-
"@types/react" ">=16.9.11"
18056-
invariant "^2.2.4"
18057-
react-lifecycles-compat "^3.0.4"
18058-
1805918007
unfetch@^4.2.0:
1806018008
version "4.2.0"
1806118009
resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be"
@@ -18491,7 +18439,7 @@ walker@^1.0.7, walker@^1.0.8:
1849118439
dependencies:
1849218440
makeerror "1.0.12"
1849318441

18494-
warning@^4.0.2, warning@^4.0.3:
18442+
warning@^4.0.2:
1849518443
version "4.0.3"
1849618444
resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3"
1849718445
integrity sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==

0 commit comments

Comments
 (0)