From 59c79ae81146cfb6b31d74dec87001439ccdacd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Fri, 19 May 2023 10:17:16 +0200 Subject: [PATCH] fix(NumberFormat): fix tooltip theme inheritance (#2354) --- .../src/components/number-format/NumberUtils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/dnb-eufemia/src/components/number-format/NumberUtils.js b/packages/dnb-eufemia/src/components/number-format/NumberUtils.js index bedcbaa9f19..3ad6d8debcf 100644 --- a/packages/dnb-eufemia/src/components/number-format/NumberUtils.js +++ b/packages/dnb-eufemia/src/components/number-format/NumberUtils.js @@ -856,13 +856,15 @@ export function showSelectionNotice({ value, label, timeout = 3e3 }) { return { run: () => {} } } - let elem, content + let elem, content, root try { + root = document.querySelector('.dnb-tooltip__portal, body') + // create that portal element elem = document.createElement('span') elem.setAttribute('id', id) - elem.setAttribute('class', 'dnb-tooltip dnb-core-style') + elem.setAttribute('class', 'dnb-tooltip') elem.setAttribute('role', 'tooltip') const arrow = document.createElement('span') @@ -882,7 +884,7 @@ export function showSelectionNotice({ value, label, timeout = 3e3 }) { return new (class SelectionFx { remove() { try { - document.body.removeChild(elem) + root.removeChild(elem) elem = null content = null } catch (e) { @@ -898,7 +900,7 @@ export function showSelectionNotice({ value, label, timeout = 3e3 }) { } run(pE = getSelectedElement()) { try { - document.body.appendChild(elem) + root.appendChild(elem) const top = getOffsetTop(pE) const left = getOffsetLeft(pE)