twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Fixed immediate UI update after Enter on single-item fields

Open RajdeepDs opened this issue 3 weeks ago • 3 comments

Previously, single-item fields maxItemCount: 1 didn’t show updated values after pressing Enter the UI only refreshed on click outside. This happened because the items list was hidden while shouldAutoEditSingleItem remained true.

This PR updates the render condition to also check !isInputDisplayed, ensuring the items list re-renders immediately after editing.

Result: Instant UI updates on Enter with no impact on multi-item fields.

Fixes #15792

RajdeepDs avatar Nov 14 '25 15:11 RajdeepDs

Greptile Overview

Greptile Summary

This PR fixes a UI update issue where single-item fields (maxItemCount: 1) didn't immediately show updated values after pressing Enter. The fix updates the render condition on line 220 from !shouldAutoEditSingleItem to (!shouldAutoEditSingleItem || !isInputDisplayed), ensuring the items list re-renders when the input is hidden.

Key Changes:

  • Modified the conditional rendering logic to also check !isInputDisplayed
  • Enables immediate UI updates on Enter for single-item fields like domain names
  • No impact on multi-item field behavior

Technical Analysis: The issue occurred because when shouldAutoEditSingleItem is true (for fields with maxItemCount === 1 and one existing item), the items list was hidden even after isInputDisplayed was set to false on Enter. The new condition (!shouldAutoEditSingleItem || !isInputDisplayed) correctly shows the list when either condition is met, resolving the delayed update.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is a minimal, surgical change to a single boolean condition that directly addresses the reported bug. The logic has been verified across multiple scenarios (single-item fields with/without existing values, multi-item fields) and maintains backward compatibility. The change follows the existing code patterns and doesn't introduce new dependencies or side effects.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/MultiItemFieldInput.tsx 5/5 Fixed UI update issue for single-item fields by updating render condition to check both shouldAutoEditSingleItem and isInputDisplayed state

Sequence Diagram

sequenceDiagram
    participant User
    participant MultiItemFieldInput
    participant State
    participant UI
    
    Note over State: Initial: items.length=1, maxItemCount=1<br/>shouldAutoEditSingleItem=true<br/>isInputDisplayed=true
    
    User->>MultiItemFieldInput: Types new value in input
    MultiItemFieldInput->>State: Update inputValue
    
    User->>MultiItemFieldInput: Presses Enter
    MultiItemFieldInput->>MultiItemFieldInput: handleSubmitInput()
    MultiItemFieldInput->>State: onChange(updatedItems)
    MultiItemFieldInput->>State: setIsInputDisplayed(false)
    
    Note over State: After Enter: items.length=1<br/>shouldAutoEditSingleItem=true<br/>isInputDisplayed=false
    
    MultiItemFieldInput->>UI: Re-render with new condition
    
    alt Before Fix (line 220)
        UI->>UI: Check: !!items.length && !shouldAutoEditSingleItem
        Note over UI: true && !true = false<br/>Items list NOT shown
    else After Fix (line 220)
        UI->>UI: Check: !!items.length && (!shouldAutoEditSingleItem || !isInputDisplayed)
        Note over UI: true && (!true || !false) = true<br/>Items list SHOWN immediately
    end
    
    UI->>User: Display updated value

greptile-apps[bot] avatar Nov 14 '25 15:11 greptile-apps[bot]

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:6535

This environment will automatically shut down when the PR is closed or after 5 hours.

github-actions[bot] avatar Nov 14 '25 15:11 github-actions[bot]

Thanks @RajdeepDs for your contribution! This marks your 1st PR on the repo. You're top 39% of all our contributors 🎉 See contributor page - Share on LinkedIn - Share on Twitter

Contributions

github-actions[bot] avatar Nov 19 '25 10:11 github-actions[bot]