The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Size auto-width Select dropdowns to the trigger (#26792)
Raphaël Bosi5378161547c8
diff --git a/packages/twenty-front/src/modules/ui/input/components/Select.tsx b/packages/twenty-front/src/modules/ui/input/components/Select.tsxindex b1af61a1351..b1690624dc0 100644--- a/packages/twenty-front/src/modules/ui/input/components/Select.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/Select.tsx@@ -61,7 +61,6 @@ export const Select = <TValue extends SelectValue>({renderAsTag = false,}: SelectProps<TValue>) => {const dropdownContentRef = useRef<HTMLDivElement>(null);- const selectContainerRef = useRef<HTMLDivElement>(null);const [searchInputValue, setSearchInputValue] = useState('');@@ -113,11 +112,6 @@ export const Select = <TValue extends SelectValue>({normalizedSearchInputValue,});- const dropDownMenuWidth =- dropdownWidthAuto && selectContainerRef.current?.clientWidth- ? selectContainerRef.current?.clientWidth- : dropdownWidth;-const controlSelectedOption = useMemo(() => {if (!isDefined(selectedOption)) {return selectedOption;@@ -153,7 +147,6 @@ export const Select = <TValue extends SelectValue>({onBlur?.();}}- ref={selectContainerRef}>{isNonEmptyString(label) && <StyledLabel>{label}</StyledLabel>}{isDisabled ? (@@ -191,7 +184,7 @@ export const Select = <TValue extends SelectValue>({) ??true}- width={dropDownMenuWidth}+ width={dropdownWidthAuto ? 'var(--anchor-width)' : dropdownWidth}align="start"sideOffset={dropdownOffset?.y ?? 0}alignOffset={dropdownOffset?.x ?? 0}diff --git a/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsx b/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsxindex b00ac24f0c2..b06de07c4c4 100644--- a/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsx@@ -201,6 +201,22 @@ export const SingleTabStopAndLabelledPopup: Story = {},};+export const DropdownWidthAutoMatchesTrigger: Story = {+ args: { fullWidth: true, dropdownWidthAuto: true },+ parameters: { container: { width: 500 } },+ play: async ({ canvasElement }) => {+ const trigger = within(canvasElement).getByRole('button');+ await userEvent.click(trigger);+ const body = within(canvasElement.ownerDocument.body);+ const popup = await body.findByRole('dialog');+ await waitFor(() =>+ expect(popup.getBoundingClientRect().width).toBe(+ trigger.getBoundingClientRect().width,+ ),+ );+ },+};+const onParentClick = fn();const onParentClickOutside = fn();const onExcludedClickOutside = fn();