@momentum-design/components 0.144.7 → 0.144.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  /* eslint-disable no-restricted-syntax */
11
- import { arrow, autoUpdate, computePosition, flip, inline as inlineMiddleware, offset, shift, size, } from '@floating-ui/dom';
11
+ import { arrow, autoUpdate, computePosition, flip, inline as inlineMiddleware, offset, platform, shift, size, } from '@floating-ui/dom';
12
12
  import { html, nothing } from 'lit';
13
13
  import { property } from 'lit/decorators.js';
14
14
  import { ifDefined } from 'lit/directives/if-defined.js';
@@ -744,6 +744,7 @@ class Popover extends KeyDownHandledMixin(KeyToActionMixin(BackdropMixin(Prevent
744
744
  placement: adjustedPlacement,
745
745
  middleware,
746
746
  strategy: this.strategy,
747
+ platform: { ...platform, getOffsetParent: element => this.utils.getOffsetParent(element) },
747
748
  });
748
749
  this.utils.updatePopoverStyle(x, y);
749
750
  if (middlewareData.arrow && this.arrowElement) {
@@ -61,6 +61,17 @@ export declare class PopoverUtils {
61
61
  x?: number;
62
62
  y?: number;
63
63
  }, placement: string): void;
64
+ /**
65
+ * Returns the offset parent that Floating UI uses to position the popover.
66
+ *
67
+ * In WebKit, Floating UI skips ancestors with `filter` or `backdrop-filter`, but Safari uses them
68
+ * as the containing block for fixed elements. For a fixed popover, use the native offset parent
69
+ * when it has a filter, unless Floating UI found a nearer containing block (e.g. in a shadow root).
70
+ *
71
+ * @param element - The element to get the offset parent for.
72
+ * @returns The offset parent of the element.
73
+ */
74
+ getOffsetParent(element: Element): Promise<Element | Window>;
64
75
  /**
65
76
  * Updates the popover style based on the x and y position.
66
77
  *
@@ -1,3 +1,4 @@
1
+ import { platform } from '@floating-ui/dom';
1
2
  import { ROLE } from '../../utils/roles';
2
3
  import { TAG_NAME as POPOVER_PORTAL_TAG_NAME } from './popover.portal.component';
3
4
  export class PopoverUtils {
@@ -202,6 +203,29 @@ export class PopoverUtils {
202
203
  [staticSide]: `${-this.popover.arrowElement.offsetHeight / 2 - arrowPixelDiff}px`,
203
204
  });
204
205
  }
206
+ /**
207
+ * Returns the offset parent that Floating UI uses to position the popover.
208
+ *
209
+ * In WebKit, Floating UI skips ancestors with `filter` or `backdrop-filter`, but Safari uses them
210
+ * as the containing block for fixed elements. For a fixed popover, use the native offset parent
211
+ * when it has a filter, unless Floating UI found a nearer containing block (e.g. in a shadow root).
212
+ *
213
+ * @param element - The element to get the offset parent for.
214
+ * @returns The offset parent of the element.
215
+ */
216
+ async getOffsetParent(element) {
217
+ const defaultParent = await platform.getOffsetParent(element);
218
+ const nativeParent = this.popover.offsetParent;
219
+ // Only the fixed popover itself needs the fix; Floating UI also calls this for the arrow.
220
+ if (element !== this.popover || this.popover.strategy !== 'fixed' || !nativeParent)
221
+ return defaultParent;
222
+ if (defaultParent instanceof Element && !defaultParent.contains(nativeParent))
223
+ return defaultParent;
224
+ const { filter, backdropFilter } = getComputedStyle(nativeParent);
225
+ // Unprefixed `backdropFilter` is undefined before Safari 18.
226
+ const hasFilter = filter !== 'none' || (!!backdropFilter && backdropFilter !== 'none');
227
+ return hasFilter ? nativeParent : defaultParent;
228
+ }
205
229
  /**
206
230
  * Updates the popover style based on the x and y position.
207
231
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@momentum-design/components",
3
3
  "packageManager": "yarn@4.18.1",
4
- "version": "0.144.7",
4
+ "version": "0.144.8",
5
5
  "engines": {
6
6
  "node": ">=24.18.0",
7
7
  "npm": ">=8.0.0"