@@ -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 } )
@@ -178,7 +174,7 @@ function ColumnConfigBody({
178174 }
179175
180176 async function handleSave ( ) {
181- if ( ! trimmedName ) {
177+ if ( config . mode === 'create' && ! trimmedName ) {
182178 setShowValidation ( true )
183179 return
184180 }
@@ -210,7 +206,6 @@ function ColumnConfigBody({
210206 return
211207 }
212208
213- const renamed = trimmedName !== ( existingColumn ?. name ?? config . columnName )
214209 const typeChanged = ! ! existingColumn && existingColumn . type !== typeInput
215210 const uniqueChanged =
216211 supportsUnique && ! ! existingColumn && ! ! existingColumn . unique !== uniqueInput
@@ -224,15 +219,13 @@ function ColumnConfigBody({
224219 wantsReference && existingColumn ?. referenceTableId !== referenceTableInput
225220
226221 const updates : {
227- name ?: string
228222 type ?: ColumnDefinition [ 'type' ]
229223 unique ?: boolean
230224 options ?: SelectOption [ ]
231225 multiple ?: boolean
232226 currencyCode ?: string
233227 referenceTableId ?: string
234228 } = {
235- ...( renamed ? { name : trimmedName } : { } ) ,
236229 ...( typeChanged ? { type : typeInput } : { } ) ,
237230 ...( uniqueChanged ? { unique : uniqueInput } : { } ) ,
238231 ...( uniqueCleared ? { unique : false } : { } ) ,
@@ -251,8 +244,7 @@ function ColumnConfigBody({
251244 }
252245
253246 await updateColumn . mutateAsync ( { columnName : config . columnName , updates } )
254- if ( renamed ) onColumnRename ?.( config . columnName , trimmedName )
255- toast . success ( `Saved "${ trimmedName } "` )
247+ toast . success ( `Saved "${ existingColumn ?. name ?? config . columnName } "` )
256248 onClose ( )
257249 } catch ( err ) {
258250 if ( isValidationError ( err ) ) {
@@ -285,23 +277,25 @@ function ColumnConfigBody({
285277 </ div >
286278
287279 < div className = 'flex-1 overflow-y-auto overflow-x-hidden px-2 pt-3 pb-2 [overflow-anchor:none]' >
288- < div className = 'flex flex-col gap-[9.5px]' >
289- < RequiredLabel htmlFor = 'column-sidebar-name' > Column name</ RequiredLabel >
290- < ChipInput
291- id = 'column-sidebar-name'
292- value = { nameInput }
293- onChange = { ( e ) => {
294- setNameInput ( e . target . value )
295- if ( nameError ) setNameError ( null )
296- } }
297- spellCheck = { false }
298- autoComplete = 'off'
299- error = { Boolean ( ( showValidation && ! trimmedName ) || nameError ) }
300- aria-invalid = { ( showValidation && ! trimmedName ) || nameError ? true : undefined }
301- />
302- { showValidation && ! trimmedName && < FieldError message = 'Column name is required' /> }
303- { nameError && ! ( showValidation && ! trimmedName ) && < FieldError message = { nameError } /> }
304- </ div >
280+ { config . mode === 'create' && (
281+ < div className = 'flex flex-col gap-[9.5px]' >
282+ < RequiredLabel htmlFor = 'column-sidebar-name' > Column name</ RequiredLabel >
283+ < ChipInput
284+ id = 'column-sidebar-name'
285+ value = { nameInput }
286+ onChange = { ( e ) => {
287+ setNameInput ( e . target . value )
288+ if ( nameError ) setNameError ( null )
289+ } }
290+ spellCheck = { false }
291+ autoComplete = 'off'
292+ error = { Boolean ( ( showValidation && ! trimmedName ) || nameError ) }
293+ aria-invalid = { ( showValidation && ! trimmedName ) || nameError ? true : undefined }
294+ />
295+ { showValidation && ! trimmedName && < FieldError message = 'Column name is required' /> }
296+ { nameError && ! ( showValidation && ! trimmedName ) && < FieldError message = { nameError } /> }
297+ </ div >
298+ ) }
305299
306300 { config . mode === 'edit' && (
307301 < >
0 commit comments