-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Follow up on FieldInput fix #16611
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?
Follow up on FieldInput fix #16611
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.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Weiko
left a comment
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.
LGTM
| const handleSubmitChanges = () => { | ||
| const { isValid, updatedItems } = validateInputAndComputeUpdatedItems(); | ||
| if (!isValid) { | ||
| return; | ||
| } | ||
|
|
||
| onChange(updatedItems); | ||
| }; |
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.
Bug: The MultiItemFieldInput component fails to reset its local state (e.g., isInputDisplayed) after submitting a new item, causing the input field to remain visible incorrectly.
Severity: HIGH | Confidence: High
🔍 Detailed Analysis
In the MultiItemFieldInput component, a refactoring removed the logic that resets the component's local state after an item is successfully submitted. Specifically, the setIsAddingNewItem(false) and setIsInputDisplayed(false) calls are missing from the handleEnter and handleSubmitChanges functions. Because isInputDisplayed and isAddingNewItem are managed by useState, they persist after submission. This causes the UI to remain in an editing state, with the input field still visible, instead of returning to its normal display state after the user adds an item.
💡 Suggested Fix
Restore the state reset logic within the handleEnter and handleSubmitChanges functions in the MultiItemFieldInput component. After a successful submission, call setIsAddingNewItem(false) and setIsInputDisplayed(false) to clean up the component's state and correctly update the UI.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/MultiItemFieldInput.tsx#L190-L197
Potential issue: In the `MultiItemFieldInput` component, a refactoring removed the logic
that resets the component's local state after an item is successfully submitted.
Specifically, the `setIsAddingNewItem(false)` and `setIsInputDisplayed(false)` calls are
missing from the `handleEnter` and `handleSubmitChanges` functions. Because
`isInputDisplayed` and `isAddingNewItem` are managed by `useState`, they persist after
submission. This causes the UI to remain in an editing state, with the input field still
visible, instead of returning to its normal display state after the user adds an item.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7601312
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.
No issues found across 2 files
Follow up on #16603