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';
33import classNames from 'classnames' ;
44import CSSMotion from '@rc-component/motion' ;
55import type { CSSMotionProps } from '@rc-component/motion' ;
6- import type { AlignType } from '../interface' ;
6+ import type { AlignType , ArrowPos } from '../interface' ;
77
88export interface UniqueBodyProps {
99 prefixCls : string ; // ${prefixCls}-unique-body
@@ -15,6 +15,7 @@ export interface UniqueBodyProps {
1515 offsetB : number ;
1616 offsetX : number ;
1717 offsetY : number ;
18+ arrowPos ?: ArrowPos ;
1819 popupSize ?: { width : number ; height : number } ;
1920 motion ?: CSSMotionProps ;
2021 uniqueBgClassName ?: string ;
@@ -32,6 +33,7 @@ const UniqueBody = (props: UniqueBodyProps) => {
3233 offsetB,
3334 offsetX,
3435 offsetY,
36+ arrowPos,
3537 popupSize,
3638 motion,
3739 uniqueBgClassName,
@@ -84,11 +86,13 @@ const UniqueBody = (props: UniqueBodyProps) => {
8486 < div
8587 className = { cls }
8688 style = { {
89+ '--arrow-x' : `${ arrowPos ?. x || 0 } px` ,
90+ '--arrow-y' : `${ arrowPos ?. y || 0 } px` ,
8791 ...offsetStyle ,
8892 ...sizeStyle ,
8993 ...motionStyle ,
9094 ...uniqueBgStyle ,
91- } }
95+ } as React . CSSProperties }
9296 />
9397 ) ;
9498 } }
Original file line number Diff line number Diff line change @@ -214,6 +214,10 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
214214 offsetB = { offsetB }
215215 offsetX = { offsetX }
216216 offsetY = { offsetY }
217+ arrowPos = { {
218+ x : arrowX ,
219+ y : arrowY ,
220+ } }
217221 popupSize = { popupSize }
218222 motion = { options . popupMotion }
219223 uniqueBgClassName = { classNames (
Original file line number Diff line number Diff line change @@ -236,6 +236,7 @@ describe('Trigger.Unique', () => {
236236 } ,
237237 } ,
238238 } }
239+ arrow
239240 >
240241 < div className = "target" > click me</ div >
241242 </ Trigger >
@@ -246,5 +247,11 @@ describe('Trigger.Unique', () => {
246247 expect ( document . querySelector ( '.rc-trigger-popup-unique-body' ) ) . toHaveClass (
247248 'bamboo' ,
248249 ) ;
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 ( '' ) ;
249256 } ) ;
250257} ) ;
You can’t perform that action at this time.
0 commit comments