File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ export default function useAlign(
204204
205205 // Placement
206206 const placementInfo : AlignType =
207- popupAlign || builtinPlacements [ placement ] || { } ;
207+ builtinPlacements [ placement ] || popupAlign || { } ;
208208
209209 // Offset
210210 const { offset, targetOffset } = placementInfo ;
Original file line number Diff line number Diff line change @@ -358,9 +358,11 @@ export function generateTrigger(
358358 triggerAlign ( ) ;
359359 } , [ mousePos ] ) ;
360360
361+ // When no builtinPlacements and popupAlign changed
361362 useLayoutEffect ( ( ) => {
362- if ( ! mergedOpen ) return ;
363- triggerAlign ( ) ;
363+ if ( mergedOpen && ! builtinPlacements ?. [ popupPlacement ] ) {
364+ triggerAlign ( ) ;
365+ }
364366 } , [ JSON . stringify ( popupAlign ) ] ) ;
365367
366368 const alignedClassName = React . useMemo ( ( ) => {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
33import React from 'react' ;
44import type { TriggerProps } from '../src' ;
55import Trigger from '../src' ;
6- import { awaitFakeTimer } from " ./util" ;
6+ import { awaitFakeTimer } from ' ./util' ;
77
88import { _rs } from 'rc-resize-observer' ;
99
@@ -108,4 +108,26 @@ describe('Trigger.Align', () => {
108108 await awaitFakeTimer ( ) ;
109109 expect ( onAlign ) . toHaveBeenCalled ( ) ;
110110 } ) ;
111+
112+ it ( 'placement is higher than popupAlign' , async ( ) => {
113+ render (
114+ < Trigger
115+ popupVisible
116+ popup = { < span className = "bamboo" /> }
117+ builtinPlacements = { {
118+ top : { } ,
119+ } }
120+ popupPlacement = "top"
121+ popupAlign = { { } }
122+ >
123+ < span />
124+ </ Trigger > ,
125+ ) ;
126+
127+ await awaitFakeTimer ( ) ;
128+
129+ expect (
130+ document . querySelector ( '.rc-trigger-popup-placement-top' ) ,
131+ ) . toBeTruthy ( ) ;
132+ } ) ;
111133} ) ;
You can’t perform that action at this time.
0 commit comments