@@ -58,9 +58,6 @@ interface ColumnConfigSidebarProps {
5858 referenceColumnsEnabled : boolean
5959 workspaceId : string
6060 tableId : string
61- /** Notify parent of a rename so it can rewrite local `columnOrder` /
62- * `columnWidths` keys that reference the old name. */
63- onColumnRename ?: ( oldName : string , newName : string ) => void
6461}
6562
6663/**
@@ -111,7 +108,6 @@ function ColumnConfigBody({
111108 referenceColumnsEnabled,
112109 workspaceId,
113110 tableId,
114- onColumnRename,
115111} : ColumnConfigBodyProps ) {
116112 const updateColumn = useUpdateColumn ( { workspaceId, tableId } )
117113 const addColumn = useAddTableColumn ( { workspaceId, tableId } )
@@ -187,7 +183,7 @@ function ColumnConfigBody({
187183 }
188184
189185 async function handleSave ( ) {
190- if ( ! trimmedName ) {
186+ if ( config . mode === 'create' && ! trimmedName ) {
191187 setShowValidation ( true )
192188 return
193189 }
@@ -219,7 +215,6 @@ function ColumnConfigBody({
219215 return
220216 }
221217
222- const renamed = trimmedName !== ( existingColumn ?. name ?? config . columnName )
223218 const typeChanged = ! ! existingColumn && existingColumn . type !== typeInput
224219 const uniqueChanged =
225220 supportsUnique && ! ! existingColumn && ! ! existingColumn . unique !== uniqueInput
@@ -233,15 +228,13 @@ function ColumnConfigBody({
233228 wantsReference && existingColumn ?. referenceTableId !== referenceTableInput
234229
235230 const updates : {
236- name ?: string
237231 type ?: ColumnDefinition [ 'type' ]
238232 unique ?: boolean
239233 options ?: SelectOption [ ]
240234 multiple ?: boolean
241235 currencyCode ?: string
242236 referenceTableId ?: string
243237 } = {
244- ...( renamed ? { name : trimmedName } : { } ) ,
245238 ...( typeChanged ? { type : typeInput } : { } ) ,
246239 ...( uniqueChanged ? { unique : uniqueInput } : { } ) ,
247240 ...( uniqueCleared ? { unique : false } : { } ) ,
@@ -260,8 +253,7 @@ function ColumnConfigBody({
260253 }
261254
262255 await updateColumn . mutateAsync ( { columnName : config . columnName , updates } )
263- if ( renamed ) onColumnRename ?.( config . columnName , trimmedName )
264- toast . success ( `Saved "${ trimmedName } "` )
256+ toast . success ( `Saved "${ existingColumn ?. name ?? config . columnName } "` )
265257 onClose ( )
266258 } catch ( err ) {
267259 if ( isValidationError ( err ) ) {
@@ -294,23 +286,25 @@ function ColumnConfigBody({
294286 </ div >
295287
296288 < div className = 'flex-1 overflow-y-auto overflow-x-hidden px-2 pt-3 pb-2 [overflow-anchor:none]' >
297- < div className = 'flex flex-col gap-[9.5px]' >
298- < RequiredLabel htmlFor = 'column-sidebar-name' > Column name</ RequiredLabel >
299- < ChipInput
300- id = 'column-sidebar-name'
301- value = { nameInput }
302- onChange = { ( e ) => {
303- setNameInput ( e . target . value )
304- if ( nameError ) setNameError ( null )
305- } }
306- spellCheck = { false }
307- autoComplete = 'off'
308- error = { Boolean ( ( showValidation && ! trimmedName ) || nameError ) }
309- aria-invalid = { ( showValidation && ! trimmedName ) || nameError ? true : undefined }
310- />
311- { showValidation && ! trimmedName && < FieldError message = 'Column name is required' /> }
312- { nameError && ! ( showValidation && ! trimmedName ) && < FieldError message = { nameError } /> }
313- </ div >
289+ { config . mode === 'create' && (
290+ < div className = 'flex flex-col gap-[9.5px]' >
291+ < RequiredLabel htmlFor = 'column-sidebar-name' > Column name</ RequiredLabel >
292+ < ChipInput
293+ id = 'column-sidebar-name'
294+ value = { nameInput }
295+ onChange = { ( e ) => {
296+ setNameInput ( e . target . value )
297+ if ( nameError ) setNameError ( null )
298+ } }
299+ spellCheck = { false }
300+ autoComplete = 'off'
301+ error = { Boolean ( ( showValidation && ! trimmedName ) || nameError ) }
302+ aria-invalid = { ( showValidation && ! trimmedName ) || nameError ? true : undefined }
303+ />
304+ { showValidation && ! trimmedName && < FieldError message = 'Column name is required' /> }
305+ { nameError && ! ( showValidation && ! trimmedName ) && < FieldError message = { nameError } /> }
306+ </ div >
307+ ) }
314308
315309 { config . mode === 'edit' && (
316310 < >
0 commit comments