@@ -109,11 +109,23 @@ export const popover = (props: PopoverProps = {}) => ({
109109 const content = this . $refs . content ;
110110 if ( content ) {
111111 content . style . visibility = 'hidden' ;
112+ // Initialize with off-screen position to avoid flashes if visibility fails
113+ content . style . left = '-9999px' ;
114+ content . style . top = '-9999px' ;
112115 }
113116
114117 this . open = true ;
115118
116119 const afterShow = ( ) => {
120+ if ( ! this . open ) return ;
121+
122+ const dimensions = this . getContentDimensions ( content ) ;
123+ // If measurement failed (0 size), Safari might not have rendered it yet. Retry.
124+ if ( dimensions . width === 0 && dimensions . height === 0 ) {
125+ requestAnimationFrame ( afterShow ) ;
126+ return ;
127+ }
128+
117129 this . updatePosition ( ) ;
118130 if ( content ) {
119131 content . style . visibility = 'visible' ;
@@ -211,6 +223,13 @@ export const popover = (props: PopoverProps = {}) => ({
211223
212224 const triggerRect = trigger . getBoundingClientRect ( ) ;
213225 const contentDimensions = this . getContentDimensions ( content ) ;
226+
227+ // If measurement failed (0 size), retry on next frame
228+ if ( this . open && contentDimensions . width === 0 && contentDimensions . height === 0 ) {
229+ requestAnimationFrame ( ( ) => this . updatePosition ( ) ) ;
230+ return ;
231+ }
232+
214233 const viewport = {
215234 width : window . innerWidth ,
216235 height : window . innerHeight ,
@@ -331,12 +350,22 @@ export const popover = (props: PopoverProps = {}) => ({
331350 } ,
332351
333352 getContentDimensions ( content : HTMLElement ) : PopoverDimensions {
334- const rect = content . getBoundingClientRect ( ) ;
353+ // Temporarily reset transforms/transitions for accurate measurement
354+ const originalTransform = content . style . transform ;
355+ const originalTransition = content . style . transition ;
356+ content . style . transform = 'none' ;
357+ content . style . transition = 'none' ;
335358
336- return {
359+ const rect = content . getBoundingClientRect ( ) ;
360+ const dimensions = {
337361 width : content . offsetWidth || rect . width ,
338362 height : content . offsetHeight || rect . height ,
339363 } ;
364+
365+ content . style . transform = originalTransform ;
366+ content . style . transition = originalTransition ;
367+
368+ return dimensions ;
340369 } ,
341370
342371 convertViewportPositionToContentPosition ( content : HTMLElement , position : { top : number ; left : number } ) {
0 commit comments