Skip to content

Commit 93b2af8

Browse files
Fixed edit container width
1 parent ff3467c commit 93b2af8

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditMode.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
useFloating,
1818
type MiddlewareState,
1919
} from '@floating-ui/react';
20-
import { useContext, type ReactElement } from 'react';
20+
import { useContext, useState, type ReactElement } from 'react';
2121

2222
const StyledEditableCellEditModeContainer = styled.div<{
2323
isFieldInputOnly: boolean;
@@ -93,9 +93,23 @@ export const RecordTableCellEditMode = ({
9393

9494
const { focusRecordTableCell } = useFocusRecordTableCell();
9595

96+
const [cellWidth, setCellWidth] = useState(0);
97+
98+
const setContainerRef = (el: HTMLDivElement | null) => {
99+
refs.setReference(el);
100+
if (el !== null) {
101+
const rect = el.getBoundingClientRect();
102+
setCellWidth(rect.width);
103+
}
104+
};
105+
const overlayWidth = Math.min(Math.max(cellWidth * 1.24, 160), 340);
106+
96107
return (
97108
<StyledEditableCellEditModeContainer
98-
ref={refs.setReference}
109+
ref={(el) => {
110+
refs.setReference(el);
111+
setContainerRef(el);
112+
}}
99113
data-testid="editable-cell-edit-mode-container"
100114
isFieldInputOnly={isFieldInputOnly}
101115
>
@@ -110,7 +124,7 @@ export const RecordTableCellEditMode = ({
110124
) : (
111125
<OverlayContainer
112126
ref={refs.setFloating}
113-
style={floatingStyles}
127+
style={{ ...floatingStyles, width: overlayWidth }}
114128
borderRadius="sm"
115129
hasDangerBorder={isFieldInError}
116130
>

0 commit comments

Comments
 (0)