1
1
import { useCallback , useRef , useState } from 'react' ;
2
2
import { useIcon } from '../../core-react/internal/hooks/useIcon' ;
3
- import { Popover } from '../../internal/primitives/Popover' ;
4
3
import { background , border , cn , pressable , text } from '../../styles/theme' ;
5
4
import { useBreakpoints } from '../../ui/react/internal/hooks/useBreakpoints' ;
5
+ import { useOutsideClick } from '../../ui/react/internal/hooks/useOutsideClick' ;
6
6
import type { SwapSettingsReact } from '../types' ;
7
7
import { SwapSettingsSlippageLayout } from './SwapSettingsSlippageLayout' ;
8
8
import { SwapSettingsSlippageLayoutBottomSheet } from './SwapSettingsSlippageLayoutBottomSheet' ;
@@ -17,11 +17,14 @@ export function SwapSettings({
17
17
const [ isOpen , setIsOpen ] = useState ( false ) ;
18
18
const dropdownRef = useRef < HTMLDivElement > ( null ) ;
19
19
20
- const handleToggle = useCallback ( ( e : React . MouseEvent ) => {
21
- e . stopPropagation ( ) ;
20
+ const handleToggle = useCallback ( ( ) => {
22
21
setIsOpen ( ( prev ) => ! prev ) ;
23
22
} , [ ] ) ;
24
23
24
+ useOutsideClick ( dropdownRef , ( ) => {
25
+ setIsOpen ( false ) ;
26
+ } ) ;
27
+
25
28
const iconSvg = useIcon ( { icon } ) ;
26
29
27
30
return (
@@ -61,28 +64,7 @@ export function SwapSettings({
61
64
</ SwapSettingsSlippageLayoutBottomSheet >
62
65
</ div >
63
66
) : (
64
- // isOpen && (
65
- // <div
66
- // className={cn(
67
- // border.radius,
68
- // background.default,
69
- // pressable.shadow,
70
- // 'absolute right-0 z-10 mt-1 w-[21.75rem] rounded-lg',
71
- // )}
72
- // data-testid="ockSwapSettingsDropdown"
73
- // >
74
- // <SwapSettingsSlippageLayout>
75
- // {children}
76
- // </SwapSettingsSlippageLayout>
77
- // </div>
78
- // )
79
- < Popover
80
- isOpen = { isOpen }
81
- onClose = { ( ) => setIsOpen ( false ) }
82
- anchorEl = { dropdownRef . current }
83
- position = "bottom"
84
- align = "end"
85
- >
67
+ isOpen && (
86
68
< div
87
69
className = { cn (
88
70
border . radius ,
@@ -96,7 +78,7 @@ export function SwapSettings({
96
78
{ children }
97
79
</ SwapSettingsSlippageLayout >
98
80
</ div >
99
- </ Popover >
81
+ )
100
82
) }
101
83
</ div >
102
84
</ div >
0 commit comments