From 15ff6131e1bcbc394a94a7a0cc424b09a7f80ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Thu, 30 Apr 2026 16:59:13 +0400 Subject: [PATCH] Fix placeholder sizing for cookie-consent elements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expand the dimensional property allowlist with padding, box-sizing, and positioning properties (position, top, right, bottom, left, inset) so placeholders match the size of absolutely or sticky positioned elements. Fall back to getComputedStyle for height when no explicit value is found from inline styles or HTML attributes. Signed-off-by: Émile Ré --- packages/cookie-banner/src/activation.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/cookie-banner/src/activation.ts b/packages/cookie-banner/src/activation.ts index 89665b844..2e6184a6c 100644 --- a/packages/cookie-banner/src/activation.ts +++ b/packages/cookie-banner/src/activation.ts @@ -146,6 +146,18 @@ function createPlaceholder( "margin-right", "margin-bottom", "margin-left", + "padding", + "padding-top", + "padding-right", + "padding-bottom", + "padding-left", + "box-sizing", + "position", + "top", + "right", + "bottom", + "left", + "inset", ]; if (htmlEl.style) { for (const prop of DIMENSIONAL_PROPS) { @@ -154,6 +166,15 @@ function createPlaceholder( } } + const hasExplicitHeight = + placeholder.style.height || placeholder.style.minHeight; + if (!hasExplicitHeight) { + const computed = window.getComputedStyle(htmlEl); + if (computed.height && computed.height !== "auto" && computed.height !== "0px") { + placeholder.style.height = computed.height; + } + } + let phText: string; if (texts?.placeholder_text) { const parts = texts.placeholder_text.split("{{category}}");