Skip to content

The open alternative to Salesforce, designed for AI.

Remove OverflowingList's layout check and document the Slider Base UI issue (#28025)

Raphaël Bosid4430b961bd7
diff --git a/packages/twenty-docs/ui/primitives/input/slider.mdx b/packages/twenty-docs/ui/primitives/input/slider.mdx
index 1c2f1070a86..977126b092e 100644
--- a/packages/twenty-docs/ui/primitives/input/slider.mdx
+++ b/packages/twenty-docs/ui/primitives/input/slider.mdx
@@ -136,6 +136,10 @@ Set `color="success"` for the alternative palette; the default is `accent`.
The default `thumbAlignment` is `edge`. Pass `center` or `edge-client-only` to override it. Native `className`, `style`, and `render` composition remain available on each part, including state functions.
+<Note>
+With `edge` and `edge-client-only` alignment, Base UI 1.8 and 1.9 never re-measure a thumb after its `Slider.Control` resizes, and a slider mounted while hidden keeps its thumbs hidden once shown ([mui/base-ui#5995](https://github.com/mui/base-ui/issues/5995)). React front components hit the same issue on their first render. Use `thumbAlignment="center"` until a Base UI release includes the fix ([mui/base-ui#6000](https://github.com/mui/base-ui/pull/6000)).
+</Note>
+
## Native integration and types
`Slider.Root` infers a number or a readonly numeric array from `value` or `defaultValue`, retaining that type in both callbacks. `SliderRootProps` accepts both by default; use `SliderRootProps<number>` for single-value helpers or `SliderRootProps<readonly number[]>` for range helpers.
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/OverflowingListLayoutEffect.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/internal/OverflowingListLayoutEffect.tsx
index 65f871b8672..ca668389fba 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/internal/OverflowingListLayoutEffect.tsx
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/OverflowingListLayoutEffect.tsx
@@ -57,7 +57,6 @@ export const OverflowingListLayoutEffect = memo(
return;
}
- const supportsSynchronousLayout = isDefined(globalThis.ResizeObserver);
const observedElements = new Set<Element>();
const measure = () => {
const itemElements = Array.from(items.children);
@@ -94,7 +93,6 @@ export const OverflowingListLayoutEffect = memo(
itemElements,
itemCount: layoutInput.itemCount,
reserveCountSpace: layoutInput.reserveCountSpace,
- supportsSynchronousLayout,
});
const previousMeasurement = previousMeasurementRef.current;
const wasUnavailableOpen =
@@ -110,7 +108,7 @@ export const OverflowingListLayoutEffect = memo(
}
};
- const observer = supportsSynchronousLayout
+ const observer = isDefined(globalThis.ResizeObserver)
? new ResizeObserver(measure)
: undefined;
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/__tests__/measureItemWidths.test.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/__tests__/measureItemWidths.test.ts
new file mode 100644
index 00000000000..aa450e800c1
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/__tests__/measureItemWidths.test.ts
@@ -0,0 +1,30 @@
+import { measureItemWidths } from '../measureItemWidths';
+
+const createMeasuredItem = ({
+ items,
+ clientWidth,
+}: {
+ items: HTMLElement;
+ clientWidth: number;
+}) => {
+ const item = document.createElement('div');
+
+ Object.defineProperty(item, 'clientWidth', {
+ get: () => (items.hasAttribute('data-measuring') ? clientWidth : 0),
+ });
+
+ return item;
+};
+
+describe('measureItemWidths', () => {
+ it('reads client widths while the measuring layout is applied', () => {
+ const items = document.createElement('div');
+ const itemElements = [
+ createMeasuredItem({ items, clientWidth: 120 }),
+ createMeasuredItem({ items, clientWidth: 90 }),
+ ];
+
+ expect(measureItemWidths({ items, itemElements })).toEqual([120, 90]);
+ expect(items.hasAttribute('data-measuring')).toBe(false);
+ });
+});
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureItemWidths.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureItemWidths.ts
index 032084e140f..18927b88063 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureItemWidths.ts
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureItemWidths.ts
@@ -1,16 +1,10 @@
export const measureItemWidths = ({
items,
itemElements,
- supportsSynchronousLayout,
}: {
items: HTMLElement;
itemElements: Element[];
- supportsSynchronousLayout: boolean;
}) => {
- if (!supportsSynchronousLayout) {
- return itemElements.map((item) => item.scrollWidth);
- }
-
items.setAttribute('data-measuring', '');
const naturalItemWidths = itemElements.map((item) => item.clientWidth);
items.removeAttribute('data-measuring');
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureOverflowingListLayout.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureOverflowingListLayout.ts
index d06cc61cda4..c5eb551a13d 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureOverflowingListLayout.ts
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureOverflowingListLayout.ts
@@ -9,7 +9,6 @@ export const measureOverflowingListLayout = ({
itemElements,
itemCount,
reserveCountSpace,
- supportsSynchronousLayout,
}: {
container: HTMLElement;
items: HTMLElement;
@@ -17,13 +16,8 @@ export const measureOverflowingListLayout = ({
itemElements: Element[];
itemCount: number;
reserveCountSpace: boolean;
- supportsSynchronousLayout: boolean;
}): OverflowingListLayout => {
- const itemWidths = measureItemWidths({
- items,
- itemElements,
- supportsSynchronousLayout,
- });
+ const itemWidths = measureItemWidths({ items, itemElements });
const gap = parseFloat(getComputedStyle(items).columnGap) || 0;
const containerWidth = container.clientWidth;
const fittedItemCount = getVisibleItemCount({
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.stories.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.stories.tsx
index eca359ab12b..cb7ff6eea14 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.stories.tsx
@@ -273,9 +273,11 @@ export const Nested: Story = {
body.queryByRole('dialog', { name: 'Sort direction' }),
).not.toBeInTheDocument(),
);
- await expect(body.getByRole('dialog', { name: 'Sort' })).toBeVisible();
+ await waitFor(() =>
+ expect(body.getByRole('dialog', { name: 'Sort' })).toBeVisible(),
+ );
const direction = body.getByRole('button', { name: 'Descending' });
- await expect(direction).toHaveFocus();
+ await waitFor(() => expect(direction).toHaveFocus());
await userEvent.click(direction);
await userEvent.keyboard('{Escape}');
await waitFor(() => expect(direction).toHaveFocus());