diff --git a/docs/testing/regression-checklist/mapping.json b/docs/testing/regression-checklist/mapping.json index 42a2a78e4f52a..291b8ced3792d 100644 --- a/docs/testing/regression-checklist/mapping.json +++ b/docs/testing/regression-checklist/mapping.json @@ -30,7 +30,7 @@ "testFile": [ "extensions/blocks/checklist.md" ] }, { - "regex": "^projects\/plugins\/jetpack\/extensions\/(blocks\/(subscriptions|premium-content)\/|shared\/memberships\.js)", + "regex": "^projects/plugins/jetpack/extensions/(blocks/(subscriptions|premium-content)/|shared/memberships.js)", "testFile": [ "extensions/blocks/subscriptions.md" ] } ] diff --git a/projects/plugins/boost/app/features/image-guide/src/index.ts b/projects/plugins/boost/app/features/image-guide/src/index.ts index 13b94497bd388..962b26fe0771b 100644 --- a/projects/plugins/boost/app/features/image-guide/src/index.ts +++ b/projects/plugins/boost/app/features/image-guide/src/index.ts @@ -104,7 +104,9 @@ function initialize() { * we don't need the guides sooner because * images have likely not loaded yet. */ -window.addEventListener( 'load', () => { - initialize(); - window.addEventListener( 'resize', debounceDimensionUpdates() ); -} ); +if ( ! window.frameElement ) { + window.addEventListener( 'load', () => { + initialize(); + window.addEventListener( 'resize', debounceDimensionUpdates() ); + } ); +} diff --git a/projects/plugins/boost/app/features/image-guide/src/initialize.ts b/projects/plugins/boost/app/features/image-guide/src/initialize.ts index dee095c403cc9..8f765ef95c3d8 100644 --- a/projects/plugins/boost/app/features/image-guide/src/initialize.ts +++ b/projects/plugins/boost/app/features/image-guide/src/initialize.ts @@ -16,9 +16,8 @@ import type { MeasurableImage } from '@automattic/jetpack-image-guide'; function getClosestContainingAncestor( node: HTMLElement ): HTMLElement | null { let current: HTMLElement | null = node.parentElement; - // Keep track of ancestor elements that do not have a "z-index" set - let elementsWithoutZIndex: HTMLElement[] = []; - + // Keep track of target element + let target: HTMLElement; while ( current && current instanceof HTMLElement ) { // Don't go past the body element if ( current === document.body ) { @@ -26,26 +25,26 @@ function getClosestContainingAncestor( node: HTMLElement ): HTMLElement | null { } const style = getComputedStyle( current ); + + // Guide can't be correctly positioned inside inline elements + // because they don't have dimensions. + const canContainBlockElements = style.display !== 'inline'; + const isStatic = style.position === 'static'; + const isRelative = style.position === 'relative'; + const hasZIndex = style.zIndex !== 'auto'; + const isRelativeWithZIndex = isRelative && hasZIndex; + if ( - style.zIndex === 'auto' && - ( style.position === 'static' || style.position === 'relative' ) + canContainBlockElements && + ( ( ! target && ( isStatic || isRelative ) ) || isRelativeWithZIndex ) ) { - elementsWithoutZIndex.push( current ); - } else { - elementsWithoutZIndex = []; + target = current; } - // Move on to the next parent element current = current.parentElement; } - // Return the first ancestor element that isn't affected by z-index - if ( elementsWithoutZIndex.length > 0 ) { - return elementsWithoutZIndex[ 0 ]; - } - - // If no element was found, return the body element - return document.body; + return target; } /** @@ -98,10 +97,7 @@ function findContainer( image: MeasurableImage ): HTMLElement | undefined { wrapper.classList.add( 'jetpack-boost-guide' ); wrapper.dataset.jetpackBoostGuideId = ( ++wrapperID ).toString(); if ( parentStyle.position === 'static' ) { - wrapper.classList.add( 'relative' ); - Array.from( ancestor.children ) - .reverse() - .forEach( child => wrapper.appendChild( child ) ); + ancestor.style.position = 'relative'; } ancestor.prepend( wrapper ); diff --git a/projects/plugins/boost/app/features/image-guide/src/ui/Bubble.svelte b/projects/plugins/boost/app/features/image-guide/src/ui/Bubble.svelte index 1b47d944c6030..1ad0a645cbc8d 100644 --- a/projects/plugins/boost/app/features/image-guide/src/ui/Bubble.svelte +++ b/projects/plugins/boost/app/features/image-guide/src/ui/Bubble.svelte @@ -1,4 +1,5 @@ -