@@ -103,4 +103,56 @@ describe('Trigger.Unique', () => {
103103 // FloatBg open prop should not have changed during transition (no close animation)
104104 expect ( global . openChangeLog ) . toHaveLength ( 0 ) ;
105105 } ) ;
106+
107+ it ( 'should add aligned className to UniqueProvider popup' , async ( ) => {
108+ const getPopupClassNameFromAlign = ( align : any ) => {
109+ return `custom-align-${ align . points ?. [ 0 ] || 'default' } ` ;
110+ } ;
111+
112+ const { container } = render (
113+ < UniqueProvider >
114+ < Trigger
115+ action = { [ 'click' ] }
116+ popup = { < strong className = "x-content" > tooltip</ strong > }
117+ unique
118+ popupPlacement = "bottomLeft"
119+ builtinPlacements = { {
120+ bottomLeft : {
121+ points : [ 'tl' , 'bl' ] ,
122+ offset : [ 0 , 4 ] ,
123+ overflow : {
124+ adjustX : 0 ,
125+ adjustY : 1 ,
126+ } ,
127+ } ,
128+ } }
129+ getPopupClassNameFromAlign = { getPopupClassNameFromAlign }
130+ >
131+ < div className = "target" > click me</ div >
132+ </ Trigger >
133+ </ UniqueProvider > ,
134+ ) ;
135+
136+ // Initially no popup should be visible
137+ expect ( document . querySelector ( '.rc-trigger-popup' ) ) . toBeFalsy ( ) ;
138+
139+ // Click trigger to show popup
140+ fireEvent . click ( container . querySelector ( '.target' ) ) ;
141+ await awaitFakeTimer ( ) ;
142+
143+ // Wait a bit more for alignment to complete
144+ await awaitFakeTimer ( ) ;
145+
146+ // Check that popup exists
147+ const popup = document . querySelector ( '.rc-trigger-popup' ) ;
148+ expect ( popup ) . toBeTruthy ( ) ;
149+ expect ( popup . querySelector ( '.x-content' ) . textContent ) . toBe ( 'tooltip' ) ;
150+
151+ // Check that custom className from getPopupClassNameFromAlign is applied
152+ expect ( popup . className ) . toContain ( 'custom-align' ) ;
153+ expect ( popup . className ) . toContain ( 'rc-trigger-popup-unique-controlled' ) ;
154+
155+ // The base placement className might not be available immediately due to async alignment
156+ // but the custom className should always be applied
157+ } ) ;
106158} ) ;
0 commit comments