@@ -13,9 +13,9 @@ import {
1313 useRefSelector ,
1414 useImmer ,
1515 useRefCallback ,
16- useContentRefConfig ,
1716 useDTransition ,
1817 useMaxIndex ,
18+ useContentSVChangeConfig ,
1919} from '../../hooks' ;
2020import { getClassName , getPopupPlacementStyle , mergeStyle } from '../../utils' ;
2121import { checkOutEl } from './utils' ;
@@ -93,7 +93,7 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
9393
9494 //#region Context
9595 const dPrefix = usePrefixConfig ( ) ;
96- const rootContentRef = useContentRefConfig ( ) ;
96+ const contentSVChange = useContentSVChangeConfig ( ) ;
9797 //#endregion
9898
9999 //#region Ref
@@ -508,19 +508,16 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
508508 } , [ asyncCapture , dEscClosable , dVisible , changeVisible ] ) ;
509509
510510 useEffect ( ( ) => {
511- const [ asyncGroup , asyncId ] = asyncCapture . createGroup ( ) ;
512511 if ( popupRendered ) {
512+ const [ asyncGroup , asyncId ] = asyncCapture . createGroup ( ) ;
513513 if ( popupEl ) {
514514 asyncGroup . onResize ( popupEl , updatePosition ) ;
515515 }
516516 if ( triggerRef . current ) {
517517 asyncGroup . onResize ( triggerRef . current , updatePosition ) ;
518518 }
519- if ( ! isFixed && rootContentRef . current ) {
520- asyncGroup . onResize ( rootContentRef . current , updatePosition ) ;
521- }
522519
523- asyncGroup . onGlobalScroll ( updatePosition , ( ) => {
520+ const skipUpdate = ( ) => {
524521 if ( triggerRef . current ) {
525522 const { top, left } = triggerRef . current . getBoundingClientRect ( ) ;
526523
@@ -530,12 +527,22 @@ const Popup: React.ForwardRefRenderFunction<DPopupRef, DPopupProps> = (props, re
530527 }
531528
532529 return false ;
530+ } ;
531+ const ob = contentSVChange ?. subscribe ( {
532+ next : ( ) => {
533+ if ( ! skipUpdate ( ) ) {
534+ updatePosition ( ) ;
535+ }
536+ } ,
533537 } ) ;
538+ asyncGroup . onGlobalScroll ( updatePosition , skipUpdate ) ;
539+
540+ return ( ) => {
541+ ob ?. unsubscribe ( ) ;
542+ asyncCapture . deleteGroup ( asyncId ) ;
543+ } ;
534544 }
535- return ( ) => {
536- asyncCapture . deleteGroup ( asyncId ) ;
537- } ;
538- } , [ asyncCapture , isFixed , popupEl , popupRendered , rootContentRef , triggerRef , updatePosition ] ) ;
545+ } , [ asyncCapture , popupEl , popupRendered , contentSVChange , triggerRef , updatePosition ] ) ;
539546
540547 useImperativeHandle (
541548 ref ,
0 commit comments