File tree Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export interface ArrowProps {
1212export default function Arrow ( props : ArrowProps ) {
1313 const { prefixCls, align, arrow, arrowPos } = props ;
1414
15- const { className, content } = arrow || { } ;
15+ const { className, content, style } = arrow || { } ;
1616 const { x = 0 , y = 0 } = arrowPos ;
1717
1818 const arrowRef = React . useRef < HTMLDivElement > ( null ) ;
@@ -58,7 +58,7 @@ export default function Arrow(props: ArrowProps) {
5858 < div
5959 ref = { arrowRef }
6060 className = { classNames ( `${ prefixCls } -arrow` , className ) }
61- style = { alignStyle }
61+ style = { { ... alignStyle , ... style } }
6262 >
6363 { content }
6464 </ div >
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ export interface AlignType {
8989}
9090
9191export interface ArrowTypeOuter {
92+ style ?: React . CSSProperties ;
9293 className ?: string ;
9394 content ?: React . ReactNode ;
9495}
Original file line number Diff line number Diff line change @@ -188,6 +188,66 @@ describe('Trigger.Arrow', () => {
188188 const arrowDom = document . querySelector ( '.rc-trigger-popup-arrow' ) ;
189189 expect ( arrowDom . classList . contains ( 'abc' ) ) . toBeTruthy ( ) ;
190190 } ) ;
191+
192+ it ( 'arrow style' , async ( ) => {
193+ render (
194+ < Trigger
195+ popupVisible
196+ popupAlign = { {
197+ points : [ 'cl' , 'cr' ] ,
198+ autoArrow : false ,
199+ } }
200+ popup = { < strong > trigger</ strong > }
201+ arrow = { {
202+ style : {
203+ color : 'red' ,
204+ backgroundColor : 'blue' ,
205+ } ,
206+ } }
207+ >
208+ < div />
209+ </ Trigger > ,
210+ ) ;
211+
212+ await awaitFakeTimer ( ) ;
213+
214+ const arrowDom = document . querySelector ( '.rc-trigger-popup-arrow' ) ;
215+ expect ( arrowDom ) . toHaveStyle ( {
216+ color : 'red' ,
217+ backgroundColor : 'blue' ,
218+ } ) ;
219+ } ) ;
220+
221+ it ( 'arrow style should merge with align style' , async ( ) => {
222+ render (
223+ < Trigger
224+ popupVisible
225+ popupAlign = { {
226+ points : [ 'cl' , 'cr' ] ,
227+ autoArrow : true ,
228+ } }
229+ popup = { < strong > trigger</ strong > }
230+ arrow = { {
231+ style : {
232+ color : 'red' ,
233+ backgroundColor : 'blue' ,
234+ } ,
235+ } }
236+ >
237+ < div />
238+ </ Trigger > ,
239+ ) ;
240+
241+ await awaitFakeTimer ( ) ;
242+
243+ const arrowDom = document . querySelector ( '.rc-trigger-popup-arrow' ) ;
244+ // Should have both align style (left: 0) and custom style
245+ expect ( arrowDom ) . toHaveStyle ( {
246+ left : 0 ,
247+ color : 'red' ,
248+ backgroundColor : 'blue' ,
249+ } ) ;
250+ } ) ;
191251 } ) ;
192252
193253 it ( 'content' , async ( ) => {
You can’t perform that action at this time.
0 commit comments