Skip to content

Commit

Permalink
Comment
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed May 10, 2022
1 parent fa2723d commit 085fd03
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/components/src/range-control/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export function useUnimpededRangedNumberEntry( { max, min, onChange, value } ) {
}
onChange( next );
};
// When the value entered in the input is out of range then a clamped value
// is sent through onChange and that goes on to update the input. In such
// circumstances this effect overwrites the input value with the entered
// value to avoid interfering with typing. E.g. Without this effect, if
// `min` is 20 and the user intends to type 25, as soon as 2 is typed the
// input will update to 20 and likely lead to an entry of 205.
useEffect( () => {
if ( ref.current && isDiverging.current ) {
const input = ref.current;
Expand Down

0 comments on commit 085fd03

Please sign in to comment.