File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
core/src/components/popover Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -491,6 +491,8 @@ export class Popover implements ComponentInterface, PopoverInterface {
491491 inline
492492 ) ;
493493
494+ this . recalculateContentOnHeaderReady ( ) ;
495+
494496 if ( ! this . keyboardEvents ) {
495497 this . configureKeyboardInteraction ( ) ;
496498 }
@@ -540,6 +542,38 @@ export class Popover implements ComponentInterface, PopoverInterface {
540542 unlock ( ) ;
541543 }
542544
545+ /**
546+ * Watch the header for height changes and trigger content dimension
547+ * recalculation when the header has a height > 0. This sets the offset-top
548+ * of the content to the height of the header correctly.
549+ */
550+ private recalculateContentOnHeaderReady ( ) {
551+ const popoverContent = this . el . shadowRoot ?. querySelector ( '.popover-content' ) ;
552+ if ( ! popoverContent ) {
553+ return ;
554+ }
555+
556+ const contentContainer = this . usersElement || popoverContent ;
557+
558+ const header = contentContainer . querySelector ( 'ion-header' ) as HTMLElement | null ;
559+ const contentElements = contentContainer . querySelectorAll ( 'ion-content' ) ;
560+
561+ if ( ! header || contentElements . length === 0 ) {
562+ return ;
563+ }
564+
565+ const ro = new ResizeObserver ( async ( ) => {
566+ if ( header . offsetHeight > 0 ) {
567+ ro . disconnect ( ) ;
568+ for ( const contentEl of contentElements ) {
569+ await contentEl . recalculateDimensions ( ) ;
570+ }
571+ }
572+ } ) ;
573+
574+ ro . observe ( header ) ;
575+ }
576+
543577 /**
544578 * Dismiss the popover overlay after it has been presented.
545579 * This is a no-op if the overlay has not been presented yet. If you want
You can’t perform that action at this time.
0 commit comments