Skip to content

Commit a5bb83e

Browse files
committed
cleanup and callback
1 parent 994357a commit a5bb83e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/components/field/field.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { palette } from '@leafygreen-ui/palette';
44
import Icon from '@leafygreen-ui/icon';
55
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
66
import { useTheme } from '@emotion/react';
7-
import { useMemo } from 'react';
7+
import { useCallback, useMemo } from 'react';
88

99
import { animatedBlueBorder, ellipsisTruncation } from '@/styles/styles';
1010
import { DEFAULT_DEPTH_SPACING, DEFAULT_FIELD_HEIGHT } from '@/utilities/constants';
@@ -210,18 +210,19 @@ export const Field = ({
210210
return internalTheme.node.mongoDBAccent;
211211
};
212212

213+
const handleNameChange = useCallback(
214+
(newName: string) => onChangeFieldName?.(nodeId, Array.isArray(id) ? id : [id], newName),
215+
[onChangeFieldName, id, nodeId],
216+
);
217+
213218
const content = (
214219
<>
215220
<FieldName>
216221
<FieldDepth depth={depth} />
217222
<FieldNameContent
218223
name={name}
219224
isEditable={editable}
220-
onChange={
221-
onChangeFieldName
222-
? (newName: string) => onChangeFieldName(nodeId, Array.isArray(id) ? id : [id], newName)
223-
: undefined
224-
}
225+
onChange={onChangeFieldName ? handleNameChange : undefined}
225226
/>
226227
</FieldName>
227228
<FieldType color={getSecondaryTextColor()}>

src/mocks/decorators/diagram-editable-interactions.decorator.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function renameField(existingFields: NodeField[], fieldPath: string[], newName:
5454
if (JSON.stringify(field.id) !== JSON.stringify(fieldPath)) return field;
5555
return { ...field, name: newName, id: [...fieldPath.slice(0, -1), newName] };
5656
});
57-
console.log('Renamed fields:', fields);
5857
return fields;
5958
}
6059

0 commit comments

Comments
 (0)