Skip to content

Follow up on FieldInput fix#16611

Merged
charlesBochet merged 5 commits intomainfrom
fix-bugs-charles-4
Dec 17, 2025
Merged

Follow up on FieldInput fix#16611
charlesBochet merged 5 commits intomainfrom
fix-bugs-charles-4

Conversation

@charlesBochet
Copy link
Copy Markdown
Member

Follow up on #16603

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a 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.

Copy link
Copy Markdown
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 190 to +197
const handleSubmitChanges = () => {
const { isValid, updatedItems } = validateInputAndComputeUpdatedItems();
if (!isValid) {
return;
}

onChange(updatedItems);
};

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

Comment on lines +193 to 200
const handleSubmitChanges = () => {
const { isValid, updatedItems } = validateInputAndComputeUpdatedItems();
if (!isValid) {
return;
}

onEnter(updatedItems);
onChange(updatedItems);
};

This comment was marked as outdated.

Comment on lines -220 to -223
? [...items, newItem]
: toSpliced(items, itemToEditIndex, 1, newItem);

onChange(updatedItems);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The handleClickOutside function in MultiItemFieldInput passes stale items to its callback, ignoring recent user modifications before the click.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

In the MultiItemFieldInput component, the handleClickOutside function passes stale data to its callback. When a user modifies an item and clicks outside the input, the validateInputAndComputeUpdatedItems function computes the new state of the items. However, the onClickOutside callback is then invoked with the original items prop, not the newly computed updatedItems. This results in the parent component receiving outdated data, leading to data loss or UI inconsistency as the user's changes are not correctly persisted.

💡 Suggested Fix

Capture the updatedItems returned from validateInputAndComputeUpdatedItems(). Then, in handleClickOutside, pass this updatedItems variable to the onClickOutside callback instead of the original items prop to ensure the parent component receives the most current data.

🤖 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#L220-L223

Potential issue: In the `MultiItemFieldInput` component, the `handleClickOutside`
function passes stale data to its callback. When a user modifies an item and clicks
outside the input, the `validateInputAndComputeUpdatedItems` function computes the new
state of the items. However, the `onClickOutside` callback is then invoked with the
original `items` prop, not the newly computed `updatedItems`. This results in the parent
component receiving outdated data, leading to data loss or UI inconsistency as the
user's changes are not correctly persisted.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7646049

@charlesBochet charlesBochet merged commit a60f750 into main Dec 17, 2025
67 checks passed
@charlesBochet charlesBochet deleted the fix-bugs-charles-4 branch December 17, 2025 13:16
@twenty-eng-sync
Copy link
Copy Markdown

Hey @charlesBochet! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

abdulrahmancodes pushed a commit that referenced this pull request Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants