@@ -617,7 +617,14 @@ function showExtraUnblockIfShortPlaceholder (shadowRoot, placeholder) {
617
617
if ( ! placeholder . parentElement ) {
618
618
return
619
619
}
620
-
620
+ const parentStyles = window . getComputedStyle ( placeholder . parentElement )
621
+ // Inline elements, like span or p, don't have a height value that we can use because they're
622
+ // not a "block" like element with defined sizes. Because we skip this check on "inline"
623
+ // parents, it might be necessary to traverse up the DOM tree until we find the nearest non
624
+ // "inline" parent to get a reliable height for this check.
625
+ if ( parentStyles . display === 'inline' ) {
626
+ return
627
+ }
621
628
const { height : placeholderHeight } = placeholder . getBoundingClientRect ( )
622
629
const { height : parentHeight } = placeholder . parentElement . getBoundingClientRect ( )
623
630
@@ -634,7 +641,7 @@ function showExtraUnblockIfShortPlaceholder (shadowRoot, placeholder) {
634
641
/** @type {HTMLElement? } */
635
642
const innerDiv = shadowRoot . querySelector ( '.DuckDuckGoSocialContainer' )
636
643
if ( innerDiv ) {
637
- innerDiv . style . minHeight = ''
644
+ innerDiv . style . minHeight = 'initial '
638
645
innerDiv . style . maxHeight = parentHeight + 'px'
639
646
innerDiv . style . overflow = 'hidden'
640
647
}
@@ -831,6 +838,17 @@ function resizeElementToMatch (sourceElement, targetElement) {
831
838
for ( const key of stylesToCopy ) {
832
839
targetElement . style [ key ] = computedStyle [ key ]
833
840
}
841
+
842
+ // If the parent element is very small (and its dimensions can be trusted) set a max height/width
843
+ // to avoid the placeholder overflowing.
844
+ if ( computedStyle . display !== 'inline' ) {
845
+ if ( targetElement . style . maxHeight < computedStyle . height ) {
846
+ targetElement . style . maxHeight = 'initial'
847
+ }
848
+ if ( targetElement . style . maxWidth < computedStyle . width ) {
849
+ targetElement . style . maxWidth = 'initial'
850
+ }
851
+ }
834
852
}
835
853
836
854
/**
0 commit comments