File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import useOffsetStyle from '../hooks/useOffsetStyle';
3
3
import classNames from 'classnames' ;
4
4
import CSSMotion from '@rc-component/motion' ;
5
5
import type { CSSMotionProps } from '@rc-component/motion' ;
6
- import type { AlignType } from '../interface' ;
6
+ import type { AlignType , ArrowPos } from '../interface' ;
7
7
8
8
export interface UniqueBodyProps {
9
9
prefixCls : string ; // ${prefixCls}-unique-body
@@ -15,6 +15,7 @@ export interface UniqueBodyProps {
15
15
offsetB : number ;
16
16
offsetX : number ;
17
17
offsetY : number ;
18
+ arrowPos ?: ArrowPos ;
18
19
popupSize ?: { width : number ; height : number } ;
19
20
motion ?: CSSMotionProps ;
20
21
uniqueBgClassName ?: string ;
@@ -32,6 +33,7 @@ const UniqueBody = (props: UniqueBodyProps) => {
32
33
offsetB,
33
34
offsetX,
34
35
offsetY,
36
+ arrowPos,
35
37
popupSize,
36
38
motion,
37
39
uniqueBgClassName,
@@ -84,11 +86,13 @@ const UniqueBody = (props: UniqueBodyProps) => {
84
86
< div
85
87
className = { cls }
86
88
style = { {
89
+ '--arrow-x' : `${ arrowPos ?. x || 0 } px` ,
90
+ '--arrow-y' : `${ arrowPos ?. y || 0 } px` ,
87
91
...offsetStyle ,
88
92
...sizeStyle ,
89
93
...motionStyle ,
90
94
...uniqueBgStyle ,
91
- } }
95
+ } as React . CSSProperties }
92
96
/>
93
97
) ;
94
98
} }
Original file line number Diff line number Diff line change @@ -214,6 +214,10 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
214
214
offsetB = { offsetB }
215
215
offsetX = { offsetX }
216
216
offsetY = { offsetY }
217
+ arrowPos = { {
218
+ x : arrowX ,
219
+ y : arrowY ,
220
+ } }
217
221
popupSize = { popupSize }
218
222
motion = { options . popupMotion }
219
223
uniqueBgClassName = { classNames (
Original file line number Diff line number Diff line change @@ -236,6 +236,7 @@ describe('Trigger.Unique', () => {
236
236
} ,
237
237
} ,
238
238
} }
239
+ arrow
239
240
>
240
241
< div className = "target" > click me</ div >
241
242
</ Trigger >
@@ -246,5 +247,11 @@ describe('Trigger.Unique', () => {
246
247
expect ( document . querySelector ( '.rc-trigger-popup-unique-body' ) ) . toHaveClass (
247
248
'bamboo' ,
248
249
) ;
250
+
251
+ // Check that arrow position CSS variables are set
252
+ const uniqueBody = document . querySelector ( '.rc-trigger-popup-unique-body' ) ;
253
+ const computedStyle = getComputedStyle ( uniqueBody ) ;
254
+ expect ( computedStyle . getPropertyValue ( '--arrow-x' ) ) . not . toBe ( '' ) ;
255
+ expect ( computedStyle . getPropertyValue ( '--arrow-y' ) ) . not . toBe ( '' ) ;
249
256
} ) ;
250
257
} ) ;
You can’t perform that action at this time.
0 commit comments