@@ -77,9 +77,6 @@ interface ColumnConfigSidebarProps {
7777 readOnly ?: boolean
7878 /** Why saving is unavailable; surfaced on the disabled Save button. */
7979 readOnlyReason ?: string
80- /** Notify parent of a rename so it can rewrite local `columnOrder` /
81- * `columnWidths` keys that reference the old name. */
82- onColumnRename ?: ( oldName : string , newName : string ) => void
8380}
8481
8582/**
@@ -132,7 +129,6 @@ function ColumnConfigBody({
132129 tableId,
133130 readOnly,
134131 readOnlyReason,
135- onColumnRename,
136132} : ColumnConfigBodyProps ) {
137133 const updateColumn = useUpdateColumn ( { workspaceId, tableId } )
138134 const addColumn = useAddTableColumn ( { workspaceId, tableId } )
@@ -210,7 +206,7 @@ function ColumnConfigBody({
210206 async function handleSave ( ) {
211207 // Belt and braces: the button is disabled, and the server refuses too.
212208 if ( readOnly ) return
213- if ( ! trimmedName ) {
209+ if ( config . mode === 'create' && ! trimmedName ) {
214210 setShowValidation ( true )
215211 return
216212 }
@@ -242,7 +238,6 @@ function ColumnConfigBody({
242238 return
243239 }
244240
245- const renamed = trimmedName !== ( existingColumn ?. name ?? config . columnName )
246241 const typeChanged = ! ! existingColumn && existingColumn . type !== typeInput
247242 const uniqueChanged =
248243 supportsUnique && ! ! existingColumn && ! ! existingColumn . unique !== uniqueInput
@@ -256,15 +251,13 @@ function ColumnConfigBody({
256251 wantsReference && existingColumn ?. referenceTableId !== referenceTableInput
257252
258253 const updates : {
259- name ?: string
260254 type ?: ColumnDefinition [ 'type' ]
261255 unique ?: boolean
262256 options ?: SelectOption [ ]
263257 multiple ?: boolean
264258 currencyCode ?: string
265259 referenceTableId ?: string
266260 } = {
267- ...( renamed ? { name : trimmedName } : { } ) ,
268261 ...( typeChanged ? { type : typeInput } : { } ) ,
269262 ...( uniqueChanged ? { unique : uniqueInput } : { } ) ,
270263 ...( uniqueCleared ? { unique : false } : { } ) ,
@@ -283,8 +276,7 @@ function ColumnConfigBody({
283276 }
284277
285278 await updateColumn . mutateAsync ( { columnName : config . columnName , updates } )
286- if ( renamed ) onColumnRename ?.( config . columnName , trimmedName )
287- toast . success ( `Saved "${ trimmedName } "` )
279+ toast . success ( `Saved "${ existingColumn ?. name ?? config . columnName } "` )
288280 onClose ( )
289281 } catch ( err ) {
290282 if ( isValidationError ( err ) ) {
@@ -321,23 +313,25 @@ function ColumnConfigBody({
321313 including the comboboxes' trigger buttons; `contents` keeps the
322314 existing layout. Values stay readable and selectable. */ }
323315 < fieldset disabled = { readOnly } className = 'contents' >
324- < div className = 'flex flex-col gap-[9.5px]' >
325- < RequiredLabel htmlFor = 'column-sidebar-name' > Column name</ RequiredLabel >
326- < ChipInput
327- id = 'column-sidebar-name'
328- value = { nameInput }
329- onChange = { ( e ) => {
330- setNameInput ( e . target . value )
331- if ( nameError ) setNameError ( null )
332- } }
333- spellCheck = { false }
334- autoComplete = 'off'
335- error = { Boolean ( ( showValidation && ! trimmedName ) || nameError ) }
336- aria-invalid = { ( showValidation && ! trimmedName ) || nameError ? true : undefined }
337- />
338- { showValidation && ! trimmedName && < FieldError message = 'Column name is required' /> }
339- { nameError && ! ( showValidation && ! trimmedName ) && < FieldError message = { nameError } /> }
340- </ div >
316+ { config . mode === 'create' && (
317+ < div className = 'flex flex-col gap-[9.5px]' >
318+ < RequiredLabel htmlFor = 'column-sidebar-name' > Column name</ RequiredLabel >
319+ < ChipInput
320+ id = 'column-sidebar-name'
321+ value = { nameInput }
322+ onChange = { ( e ) => {
323+ setNameInput ( e . target . value )
324+ if ( nameError ) setNameError ( null )
325+ } }
326+ spellCheck = { false }
327+ autoComplete = 'off'
328+ error = { Boolean ( ( showValidation && ! trimmedName ) || nameError ) }
329+ aria-invalid = { ( showValidation && ! trimmedName ) || nameError ? true : undefined }
330+ />
331+ { showValidation && ! trimmedName && < FieldError message = 'Column name is required' /> }
332+ { nameError && ! ( showValidation && ! trimmedName ) && < FieldError message = { nameError } /> }
333+ </ div >
334+ ) }
341335
342336 { config . mode === 'edit' && (
343337 < >
0 commit comments