Skip to content

Commit 8afc3f5

Browse files
committed
refactor: introduce Anchor Position API
1 parent 25b2e76 commit 8afc3f5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/components/src/components/tooltip/tooltip.lite.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,16 @@ export default function DBTooltip(props: DBTooltipProps) {
5252
return parent;
5353
},
5454
handleAutoPlacement: (parent?: HTMLElement) => {
55-
if (!parent) return;
56-
if (_ref) {
55+
if (!parent || !_ref) return;
56+
57+
// Check if CSS Anchor Positioning API is supported
58+
const supportsAnchorPositioning =
59+
typeof window !== 'undefined' &&
60+
CSS.supports('anchor-name', '--anchor') &&
61+
CSS.supports('position-anchor', '--anchor');
62+
63+
// Fallback to existing JavaScript implementation
64+
if (!supportsAnchorPositioning) {
5765
// This is a workaround for angular
5866
utilsDelay(() => {
5967
handleFixedPopover(

0 commit comments

Comments
 (0)