Skip to content

The open alternative to Salesforce, designed for AI.

Match the floating text editor width to its field on record pages (#26124)

Charles Bochete8e10f56ac28
diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellEditMode.tsx b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellEditMode.tsx
index 536d3209073..44584300992 100644
--- a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellEditMode.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellEditMode.tsx
@@ -4,6 +4,7 @@ import { recordFieldInputIsFieldInErrorComponentState } from '@/object-record/re
import { recordFieldInputLayoutDirectionComponentState } from '@/object-record/record-field/ui/states/recordFieldInputLayoutDirectionComponentState';
import { recordFieldInputLayoutDirectionLoadingComponentState } from '@/object-record/record-field/ui/states/recordFieldInputLayoutDirectionLoadingComponentState';
import { RecordInlineCellContext } from '@/object-record/record-inline-cell/components/RecordInlineCellContext';
+import { FIELD_INPUT_ANCHOR_WIDTH_CSS_VARIABLE } from '@/ui/field/input/constants/FieldInputAnchorWidthCssVariable';
import { StyledDropdownContentContainer } from '@/ui/layout/dropdown/components/internal/DropdownInternalContainer';
import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
@@ -15,6 +16,7 @@ import {
flip,
offset,
shift,
+ size,
useFloating,
type MiddlewareState,
} from '@floating-ui/react';
@@ -84,6 +86,14 @@ export const RecordInlineCellEditMode = ({
};
}),
shift({ padding: 8 }),
+ size({
+ apply: ({ rects, elements }) => {
+ elements.floating.style.setProperty(
+ FIELD_INPUT_ANCHOR_WIDTH_CSS_VARIABLE,
+ `${rects.reference.width}px`,
+ );
+ },
+ }),
setFieldInputLayoutDirectionMiddleware,
],
whileElementsMounted: autoUpdate,
diff --git a/packages/twenty-front/src/modules/ui/field/input/components/DoubleTextInput.tsx b/packages/twenty-front/src/modules/ui/field/input/components/DoubleTextInput.tsx
index bf6b87a462a..7ee842cf317 100644
--- a/packages/twenty-front/src/modules/ui/field/input/components/DoubleTextInput.tsx
+++ b/packages/twenty-front/src/modules/ui/field/input/components/DoubleTextInput.tsx
@@ -22,6 +22,7 @@ import { themeCssVariables } from 'twenty-ui/theme-constants';
const StyledContainer = styled.div`
display: flex;
justify-content: space-between;
+ width: 100%;
& > input:last-child {
border-left: 1px solid ${themeCssVariables.border.color.strong};
diff --git a/packages/twenty-front/src/modules/ui/field/input/components/FieldInputContainer.tsx b/packages/twenty-front/src/modules/ui/field/input/components/FieldInputContainer.tsx
index 81cb1847b8b..e853ccbb968 100644
--- a/packages/twenty-front/src/modules/ui/field/input/components/FieldInputContainer.tsx
+++ b/packages/twenty-front/src/modules/ui/field/input/components/FieldInputContainer.tsx
@@ -1,10 +1,12 @@
import { styled } from '@linaria/react';
+import { FIELD_INPUT_ANCHOR_WIDTH_CSS_VARIABLE } from '@/ui/field/input/constants/FieldInputAnchorWidthCssVariable';
+
// oxlint-disable-next-line twenty/styled-components-prefixed-with-styled
export const FieldInputContainer = styled.div`
align-items: center;
display: flex;
min-height: 32px;
- min-width: 200px;
+ min-width: max(200px, var(${FIELD_INPUT_ANCHOR_WIDTH_CSS_VARIABLE}, 0px));
width: 100%;
`;
diff --git a/packages/twenty-front/src/modules/ui/field/input/components/TextAreaInput.tsx b/packages/twenty-front/src/modules/ui/field/input/components/TextAreaInput.tsx
index 2e20ee18f31..8fa6de196cf 100644
--- a/packages/twenty-front/src/modules/ui/field/input/components/TextAreaInput.tsx
+++ b/packages/twenty-front/src/modules/ui/field/input/components/TextAreaInput.tsx
@@ -26,6 +26,8 @@ export type TextAreaInputProps = {
};
const StyledTextAreaContainer = styled.div`
+ width: 100%;
+
> textarea {
align-items: center;
background-color: transparent;
diff --git a/packages/twenty-front/src/modules/ui/field/input/constants/FieldInputAnchorWidthCssVariable.ts b/packages/twenty-front/src/modules/ui/field/input/constants/FieldInputAnchorWidthCssVariable.ts
new file mode 100644
index 00000000000..7d4e2acc167
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/field/input/constants/FieldInputAnchorWidthCssVariable.ts
@@ -0,0 +1,2 @@
+export const FIELD_INPUT_ANCHOR_WIDTH_CSS_VARIABLE =
+ '--field-input-anchor-width';