@@ -22,8 +22,6 @@ export interface AlignProps {
2222 monitorWindowResize ?: boolean ;
2323 disabled ?: boolean ;
2424 children : React . ReactElement ;
25- /** Always trigger align with each render */
26- keepAlign ?: boolean ;
2725}
2826
2927interface MonitorRef {
@@ -45,27 +43,11 @@ function getPoint(point: TargetType) {
4543 return point ;
4644}
4745
48- interface InternalTestProps {
49- INTERNAL_TRIGGER_ALIGN ?: Function ;
50- }
51-
5246const Align : React . RefForwardingComponent < RefAlign , AlignProps > = (
53- {
54- children,
55- disabled,
56- target,
57- align,
58- onAlign,
59- monitorWindowResize,
60- monitorBufferTime = 0 ,
61- keepAlign,
62- ...restProps
63- } ,
47+ { children, disabled, target, align, onAlign, monitorWindowResize, monitorBufferTime = 0 } ,
6448 ref ,
6549) => {
66- const cacheRef = React . useRef < { element ?: HTMLElement ; point ?: TargetPoint } > (
67- { } ,
68- ) ;
50+ const cacheRef = React . useRef < { element ?: HTMLElement ; point ?: TargetPoint } > ( { } ) ;
6951 const nodeRef = React . useRef ( ) ;
7052 let childNode = React . Children . only ( children ) ;
7153
@@ -81,17 +63,7 @@ const Align: React.RefForwardingComponent<RefAlign, AlignProps> = (
8163 forceAlignPropsRef . current . onAlign = onAlign ;
8264
8365 const [ forceAlign , cancelForceAlign ] = useBuffer ( ( ) => {
84- if (
85- process . env . NODE_ENV !== 'production' &&
86- ( restProps as InternalTestProps ) . INTERNAL_TRIGGER_ALIGN
87- ) {
88- ( restProps as InternalTestProps ) . INTERNAL_TRIGGER_ALIGN ( ) ;
89- }
90-
91- const {
92- disabled : latestDisabled ,
93- target : latestTarget ,
94- } = forceAlignPropsRef . current ;
66+ const { disabled : latestDisabled , target : latestTarget } = forceAlignPropsRef . current ;
9567 if ( ! latestDisabled && latestTarget ) {
9668 const source = nodeRef . current ;
9769
@@ -140,16 +112,10 @@ const Align: React.RefForwardingComponent<RefAlign, AlignProps> = (
140112 if ( nodeRef . current !== sourceResizeMonitor . current . element ) {
141113 sourceResizeMonitor . current . cancel ( ) ;
142114 sourceResizeMonitor . current . element = nodeRef . current ;
143- sourceResizeMonitor . current . cancel = monitorResize (
144- nodeRef . current ,
145- forceAlign ,
146- ) ;
115+ sourceResizeMonitor . current . cancel = monitorResize ( nodeRef . current , forceAlign ) ;
147116 }
148117
149- if (
150- cacheRef . current . element !== element ||
151- ! isSamePoint ( cacheRef . current . point , point )
152- ) {
118+ if ( cacheRef . current . element !== element || ! isSamePoint ( cacheRef . current . point , point ) ) {
153119 forceAlign ( ) ;
154120
155121 // Add resize observer
@@ -170,15 +136,6 @@ const Align: React.RefForwardingComponent<RefAlign, AlignProps> = (
170136 }
171137 } , [ disabled ] ) ;
172138
173- /**
174- * [Legacy] Should keep re-algin since we don't know if target position changed.
175- */
176- React . useEffect ( ( ) => {
177- if ( keepAlign && ! disabled ) {
178- forceAlign ( true ) ;
179- }
180- } ) ;
181-
182139 // Listen for window resize
183140 const winResizeRef = React . useRef < { remove : Function } > ( null ) ;
184141 React . useEffect ( ( ) => {
0 commit comments