Skip to content

Commit

Permalink
Fix manual entry within Quantity Inputs (woocommerce#5197)
Browse files Browse the repository at this point in the history
* Use Number.isNaN to cast strings

* Avoid changing type function
  • Loading branch information
mikejolley authored and jonny-bull committed Dec 16, 2021
1 parent 0bc7efc commit d50d23e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/js/base/components/quantity-selector/index.tsx
Expand Up @@ -6,7 +6,6 @@ import { speak } from '@wordpress/a11y';
import classNames from 'classnames';
import { useCallback } from '@wordpress/element';
import { DOWN, UP } from '@wordpress/keycodes';
import { isNumber } from '@woocommerce/types';

/**
* Internal dependencies
Expand Down Expand Up @@ -84,7 +83,8 @@ const QuantitySelector = ( {
onKeyDown={ quantityInputOnKeyDown }
onChange={ ( event ) => {
let value =
! isNumber( event.target.value ) || ! event.target.value
Number.isNaN( event.target.value ) ||
! event.target.value
? 0
: parseInt( event.target.value, 10 );
if ( hasMaximum ) {
Expand Down

0 comments on commit d50d23e

Please sign in to comment.