Skip to content

Commit

Permalink
Fix input control blur logic, so that onChange is called after clam…
Browse files Browse the repository at this point in the history
…ping the value
  • Loading branch information
ciampo committed Mar 9, 2022
1 parent 80982d0 commit cbf0bef
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/components/src/input-control/input-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ function InputField(
onBlur( event );
setIsFocused?.( false );

// If isPressEnterToChange is set, cause the `onChange` callback to be fired.
if ( isPressEnterToChange && isDirty ) {
/**
* If isPressEnterToChange is set, this commits the value to
* the onChange callback.
*/
if ( isDirty || ! event.target.validity.valid ) {
wasDirtyOnBlur.current = true;
handleOnCommit( event );
}

// Commit the value (which allows consumers to apply their validation)
handleOnCommit( event );
};

const handleOnFocus = ( event: FocusEvent< HTMLInputElement > ) => {
Expand Down

0 comments on commit cbf0bef

Please sign in to comment.