react-spectrum
Fix: Wrap commit() in flushSync on Enter in NumberField
#9683
Merged

Commits
  • Fix: Wrap commit() in flushSync on Enter in useNumberField When Enter is pressed in NumberField, commit() was called without flushSync, unlike the blur handler which wraps commit() in flushSync. This caused controlled form libraries reading React state immediately after Enter to receive stale values instead of the committed value. The browser synthesizes a trusted click on the form's submit button when Enter is pressed, firing onSubmit before the unguarded commit() has flushed to React state. This change wraps commit() in flushSync on Enter, making it consistent with the blur behavior and ensuring the value is flushed synchronously before any consumer reads form state. Fixes #9671
    tariqrasheed172001 committed 21 days ago
  • Merge branch 'main' into fix/numberfield-enter-flushsync
    tariqrasheed172001 committed 20 days ago
Loading