Skip to content

Commit fd5b5c9

Browse files
Copilothotlong
andcommitted
fix: address code review feedback - disable field type selector, simplify width validation, improve test assertions
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 7de9274 commit fd5b5c9

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

packages/plugin-designer/src/ViewDesigner.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,8 @@ export function ViewDesigner({
754754
<label className="text-xs text-muted-foreground">Field Type</label>
755755
<select
756756
value={availableFields.find((f) => f.name === columns[selectedColumnIndex].field)?.type ?? 'text'}
757-
onChange={(e) => {
758-
if (readOnly) return;
759-
// Field type is informational — stored on the availableField, not the column
760-
}}
761-
className="w-full px-2 py-1 text-sm border rounded bg-background mt-1"
762-
disabled={readOnly}
757+
disabled
758+
className="w-full px-2 py-1 text-sm border rounded bg-muted/50 mt-1"
763759
data-testid="column-field-type"
764760
>
765761
{DESIGNER_FIELD_TYPES.map((ft) => (
@@ -780,7 +776,7 @@ export function ViewDesigner({
780776
const val = e.target.value;
781777
if (val === '' || val === 'auto') {
782778
pushState({
783-
columns: columns.map((c, i) => (i === idx ? { ...c, width: val || undefined } : c)),
779+
columns: columns.map((c, i) => (i === idx ? { ...c, width: val === 'auto' ? 'auto' : undefined } : c)),
784780
});
785781
return;
786782
}

packages/plugin-designer/src/__tests__/DataModelDesigner.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,17 @@ describe('DataModelDesigner', () => {
192192
const onChange = vi.fn();
193193
render(<DataModelDesigner entities={MOCK_ENTITIES} onEntitiesChange={onChange} />);
194194

195+
const callCountBefore = onChange.mock.calls.length;
196+
195197
const label = screen.getByTestId('entity-label-entity-1');
196198
fireEvent.doubleClick(label);
197199

198200
const input = screen.getByTestId('entity-label-input-entity-1');
199201
fireEvent.change(input, { target: { value: ' ' } });
200202
fireEvent.keyDown(input, { key: 'Enter' });
201203

202-
// Should not have committed (no onEntitiesChange beyond any prior calls)
204+
// Should not have committed (no additional onEntitiesChange call)
205+
expect(onChange.mock.calls.length).toBe(callCountBefore);
203206
// The input should be gone (editing cancelled)
204207
expect(screen.queryByTestId('entity-label-input-entity-1')).toBeNull();
205208
});

0 commit comments

Comments
 (0)