-
Notifications
You must be signed in to change notification settings - Fork 1
feat/COMPASS-9798 inline field name editing #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, haven't tried it out a yet. Left a couple small comments (not blockers).
src/mocks/decorators/diagram-editable-interactions.decorator.tsx
Outdated
Show resolved
Hide resolved
625b464
to
aedb6b8
Compare
97ee430
to
6c91c2a
Compare
@Anemy switched to input and updated styles so that there is something to click on even if the name is very short or empty (which we want to prevent but I don't think we can do it here since the error handling is planned in compass) |
6c91c2a
to
fd01f84
Compare
|
||
export const FieldNameContent = ({ name, isEditable, onChange }: FieldNameProps) => { | ||
const [isEditing, setIsEditing] = useState(false); | ||
const [value, setValue] = useState(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would name ever change externally? Would we need a useEffect
to re-hydrate this state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might actually, we have a sidebar where they can edit too
|
||
useEffect(() => { | ||
if (isEditing) { | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this setTimeout
used for? Do we need this?
setValue(e.target.value); | ||
}} | ||
onBlur={handleSubmit} | ||
onKeyDown={e => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this and the onDoubleClick
into its own function for better readability, like the other components in this repo?
onBlur?: () => void; | ||
} | ||
|
||
export const FieldNameContent = ({ name, isEditable, onChange }: FieldNameProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to have two seperate components, one which is editable and the other (the current flow) which is not? At the moment we're passing in quite a few (optional) props which require a conditional check, especially in that useEffect
. I could see someone accidentally adding in a change which re-renders this whole component too, rather than just the edited component and vice-versa
onBlur={handleSubmit} | ||
onKeyDown={e => { | ||
if (e.key === 'Enter') handleSubmit(); | ||
if (e.key === 'Escape') setIsEditing(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it's more expected behaviour to reset the field name to it's original value on Escape
as opposed to committing the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small UX detail, otherwise implementation LGTM
External Links
Description
If the field is editable, and onFieldNameChange is provided, the field becomes editable on double click.
The style is minimalistic, in line with the inline inputs in Compass CRUD.
Note: I did try LG text input but the customization needed goes beyond what the component supports
Notes for Reviewers
πΈ Screenshots/Screencasts
Screen.Recording.2025-09-26.at.13.10.33.mov
Before
After