Skip to content

The open alternative to Salesforce, designed for AI.

Restore native blur in front component menus (#28980)

Raphaël Bosi56d4e1f68105
diff --git a/packages/twenty-front-component-renderer/src/__stories__/shared/test-utils/matchers/expectElementBackdropToReachHostPage.ts b/packages/twenty-front-component-renderer/src/__stories__/shared/test-utils/matchers/expectElementBackdropToReachHostPage.ts
new file mode 100644
index 00000000000..a04f38858c1
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/shared/test-utils/matchers/expectElementBackdropToReachHostPage.ts
@@ -0,0 +1,14 @@
+import { expect } from 'storybook/test';
+import { isDefined } from 'twenty-shared/utils';
+
+export const expectElementBackdropToReachHostPage = (element: Element) => {
+ expect(getComputedStyle(element).backdropFilter).not.toBe('none');
+
+ for (
+ let ancestor = element.parentElement;
+ isDefined(ancestor);
+ ancestor = ancestor.parentElement
+ ) {
+ expect(getComputedStyle(ancestor).clipPath).toBe('none');
+ }
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-select.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-select.front-component.tsx
index 4287fdf6e09..eb361dbecba 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-select.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-select.front-component.tsx
@@ -58,7 +58,7 @@ const SelectExample = () => {
collisionAvoidance={{ side: 'flip', align: 'shift' }}
data-select-positioner="stage"
>
- <Select.Popup>
+ <Select.Popup data-testid="stage-popup">
<Select.List render={<ul />}>
<Select.Group>
<Select.GroupLabel>Active stages</Select.GroupLabel>
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/portalBoundsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/portalBoundsTest.ts
index 308ec7a898b..787a6e4d7c6 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/portalBoundsTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/portalBoundsTest.ts
@@ -1,6 +1,7 @@
import { expect, userEvent, waitFor, within } from 'storybook/test';
import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { expectElementBackdropToReachHostPage } from '@/__stories__/shared/test-utils/matchers/expectElementBackdropToReachHostPage';
import { expectElementToReceivePointer } from '@/__stories__/shared/test-utils/matchers/expectElementToReceivePointer';
import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
import { MAXIMUM_DROPDOWN_TRIGGER_GAP } from '@/__stories__/twenty-ui-gallery/constants/MaximumDropdownTriggerGap';
@@ -11,6 +12,7 @@ import { waitForGeometryTrackerToIdle } from '@/__stories__/twenty-ui-gallery/ut
import { FRONT_COMPONENT_PORTAL_MARGIN } from '@/constants/FrontComponentPortalMargin';
const WIDGET_SCROLL_OFFSET = 40;
+const PORTAL_BOUNDARY_OFFSET = 1;
const expectPortalActionAtOwnerBottom = ({
portalAction,
@@ -176,9 +178,12 @@ export const portalBoundsTest: TwentyUiGalleryPlayFunction = async ({
name: 'Menu item 1',
});
await waitFor(() => {
+ const menu = page.getByRole('menu');
+
+ expectElementBackdropToReachHostPage(menu);
expectElementToReceivePointer(firstMenuItem);
expectDropdownAttachedToTriggerWithinPortalArea({
- menu: page.getByRole('menu'),
+ menu,
menuTrigger,
ownerRoot,
});
@@ -204,6 +209,21 @@ export const portalBoundsTest: TwentyUiGalleryPlayFunction = async ({
),
),
).toBe(true);
+ const portalBoundaryLeft =
+ ownerRectangle.left - FRONT_COMPONENT_PORTAL_MARGIN;
+ const portalCenterY = ownerRectangle.top + ownerRectangle.height / 2;
+
+ const insidePortalBoundary = hostDocument.elementFromPoint(
+ portalBoundaryLeft + PORTAL_BOUNDARY_OFFSET,
+ portalCenterY,
+ );
+ const outsidePortalBoundary = hostDocument.elementFromPoint(
+ portalBoundaryLeft - PORTAL_BOUNDARY_OFFSET,
+ portalCenterY,
+ );
+
+ expect(oversizedPortal.contains(insidePortalBoundary)).toBe(true);
+ expect(oversizedPortal.contains(outsidePortalBoundary)).toBe(false);
expectElementToReceivePointer(hostAction);
await userEvent.click(hostAction);
expect(
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/selectTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/selectTest.ts
index fc29bc6615a..8d78c5d6993 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/selectTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/selectTest.ts
@@ -1,6 +1,7 @@
import { expect, userEvent, waitFor, within } from 'storybook/test';
import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { expectElementBackdropToReachHostPage } from '@/__stories__/shared/test-utils/matchers/expectElementBackdropToReachHostPage';
import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
import { INTERACTION_TIMEOUT } from '@/__stories__/shared/test-utils/timeouts';
import { waitForSandboxRoundTrip } from '@/__stories__/shared/test-utils/waitForSandboxRoundTrip';
@@ -32,6 +33,7 @@ export const selectTest: TwentyUiGalleryPlayFunction = async ({
await waitFor(() => expect(qualified).toBeVisible(), {
timeout: INTERACTION_TIMEOUT,
});
+ expectElementBackdropToReachHostPage(page.getByTestId('stage-popup'));
expect(qualified.tagName).toBe('LI');
expect(archived).toHaveAttribute('aria-disabled', 'true');
expect(qualified.closest('[data-select-positioner="stage"]')).toHaveStyle({
diff --git a/packages/twenty-front-component-renderer/src/host/components/FrontComponentRemoteRootRenderer.tsx b/packages/twenty-front-component-renderer/src/host/components/FrontComponentRemoteRootRenderer.tsx
index 92bee3282e6..dd2c7112a09 100644
--- a/packages/twenty-front-component-renderer/src/host/components/FrontComponentRemoteRootRenderer.tsx
+++ b/packages/twenty-front-component-renderer/src/host/components/FrontComponentRemoteRootRenderer.tsx
@@ -20,7 +20,16 @@ const PORTAL_LAYER_STYLE: CSSProperties = {
contain: 'layout',
zIndex: PORTAL_LAYER_Z_INDEX,
pointerEvents: 'none',
- clipPath: `inset(calc(-${FRONT_COMPONENT_PORTAL_MARGIN}px / var(--t-zoom, 1)))`,
+ overflow: 'clip',
+ boxSizing: 'content-box',
+ padding: `calc(${FRONT_COMPONENT_PORTAL_MARGIN}px / var(--t-zoom, 1))`,
+ margin: `calc(-${FRONT_COMPONENT_PORTAL_MARGIN}px / var(--t-zoom, 1))`,
+};
+
+const PORTAL_COORDINATE_STYLE: CSSProperties = {
+ contain: 'layout',
+ width: '100%',
+ height: '100%',
};
const PORTAL_CONTENT_STYLE: CSSProperties = {
@@ -49,8 +58,10 @@ export const FrontComponentRemoteRootRenderer = (
{isNonEmptyArray(portalChildren) &&
createPortal(
<div ref={geometryTracker?.setPortalLayer} style={PORTAL_LAYER_STYLE}>
- <div style={PORTAL_CONTENT_STYLE}>
- {portalChildren.map((child) => renderRemoteNode(child, props))}
+ <div style={PORTAL_COORDINATE_STYLE}>
+ <div style={PORTAL_CONTENT_STYLE}>
+ {portalChildren.map((child) => renderRemoteNode(child, props))}
+ </div>
</div>
</div>,
document.body,