From 1c2d8bf01f5bab04f7d8714def531af27f4b7b14 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 25 Aug 2022 11:49:09 +0200 Subject: [PATCH] feat(Tooltip): add omit_portal property --- .../__snapshots__/Dialog.test.tsx.snap | 3 +++ .../__snapshots__/Drawer.test.tsx.snap | 3 +++ .../__snapshots__/Modal.test.tsx.snap | 3 +++ .../src/components/tooltip/Tooltip.js | 18 +++++++++++++----- .../src/components/tooltip/TooltipContainer.js | 6 +----- .../__snapshots__/Tooltip.test.js.snap | 3 +++ 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap b/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap index b62c917321c..f15e8afb9ca 100644 --- a/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap +++ b/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap @@ -437,6 +437,7 @@ exports[`Dialog component snapshot should match component snapshot 1`] = ` hide_delay={500} id="dialog_id-tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" @@ -502,6 +503,7 @@ exports[`Dialog component snapshot should match component snapshot 1`] = ` id="dialog_id-tooltip" internal_id="dialog_id-tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" @@ -610,6 +612,7 @@ exports[`Dialog component snapshot should match component snapshot 1`] = ` internal_id="dialog_id-tooltip" key="tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" diff --git a/packages/dnb-eufemia/src/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap b/packages/dnb-eufemia/src/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap index 9b9556cc62b..da96f1c0133 100644 --- a/packages/dnb-eufemia/src/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +++ b/packages/dnb-eufemia/src/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap @@ -435,6 +435,7 @@ exports[`Drawer component snapshot should match component snapshot 1`] = ` hide_delay={500} id="drawer_id-tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" @@ -500,6 +501,7 @@ exports[`Drawer component snapshot should match component snapshot 1`] = ` id="drawer_id-tooltip" internal_id="drawer_id-tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" @@ -608,6 +610,7 @@ exports[`Drawer component snapshot should match component snapshot 1`] = ` internal_id="drawer_id-tooltip" key="tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" diff --git a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap index c8ce54e133d..8249ab03de6 100644 --- a/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap +++ b/packages/dnb-eufemia/src/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap @@ -426,6 +426,7 @@ exports[`Modal component have to match snapshot 1`] = ` hide_delay={500} id="modal_id-tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" @@ -491,6 +492,7 @@ exports[`Modal component have to match snapshot 1`] = ` id="modal_id-tooltip" internal_id="modal_id-tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" @@ -599,6 +601,7 @@ exports[`Modal component have to match snapshot 1`] = ` internal_id="modal_id-tooltip" key="tooltip" no_animation={false} + omit_portal={null} position="top" show_delay={300} size="basis" diff --git a/packages/dnb-eufemia/src/components/tooltip/Tooltip.js b/packages/dnb-eufemia/src/components/tooltip/Tooltip.js index 101cb1f105b..3de98ba1f64 100644 --- a/packages/dnb-eufemia/src/components/tooltip/Tooltip.js +++ b/packages/dnb-eufemia/src/components/tooltip/Tooltip.js @@ -18,6 +18,7 @@ import { spacingPropTypes, createSpacingClasses, } from '../space/SpacingHelper' +import TooltipContainer from './TooltipContainer' import TooltipWithEvents from './TooltipWithEvents' import TooltipPortal from './TooltipPortal' import { injectTooltipSemantic } from './TooltipHelpers' @@ -51,6 +52,7 @@ export default class Tooltip extends React.PureComponent { PropTypes.string, PropTypes.bool, ]), + omit_portal: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), no_animation: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), show_delay: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), hide_delay: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), @@ -82,6 +84,7 @@ export default class Tooltip extends React.PureComponent { align: null, animate_position: false, fixed_position: false, + omit_portal: null, no_animation: false, show_delay: 300, hide_delay: 500, @@ -140,6 +143,7 @@ export default class Tooltip extends React.PureComponent { size, animate_position, // eslint-disable-line fixed_position, // eslint-disable-line + omit_portal, no_animation, // eslint-disable-line show_delay, // eslint-disable-line hide_delay, // eslint-disable-line @@ -178,13 +182,17 @@ export default class Tooltip extends React.PureComponent { delete newProps.active } - // React.isValidElement(target) || - // (typeof target === 'object' && - // Object.prototype.hasOwnProperty.call(target, 'current')) - return ( <> - {target_element ? ( + {omit_portal ? ( + + {content} + + ) : target_element ? (