Use non negative value change handler for quantity input
This commit is contained in:
parent
8abe279248
commit
f85ca42d36
2 changed files with 8 additions and 5 deletions
|
@ -15,6 +15,7 @@ import Skeleton from "@saleor/components/Skeleton";
|
|||
import TableCellAvatar, {
|
||||
AVATAR_MARGIN
|
||||
} from "@saleor/components/TableCellAvatar";
|
||||
import createNonNegativeValueChangeHandler from "@saleor/utils/handlers/nonNegativeValueChangeHandler";
|
||||
import React from "react";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
|
||||
|
@ -165,11 +166,9 @@ const OrderDraftDetailsProducts: React.FC<OrderDraftDetailsProductsProps> = prop
|
|||
onSubmit={data => onOrderLineChange(line.id, data)}
|
||||
>
|
||||
{({ change, data, hasChanged, submit }) => {
|
||||
const handleQuantityChange = event => {
|
||||
if (/^\d*(\.\d+)?$/.test(event.target.value)) {
|
||||
change(event);
|
||||
}
|
||||
};
|
||||
const handleQuantityChange = createNonNegativeValueChangeHandler(
|
||||
change
|
||||
);
|
||||
|
||||
return (
|
||||
<DebounceForm
|
||||
|
|
|
@ -108894,6 +108894,7 @@ exports[`Storyshots Views / Orders / Order draft default 1`] = `
|
|||
<input
|
||||
aria-invalid="false"
|
||||
class="MuiInputBase-input-id MuiOutlinedInput-input-id"
|
||||
min="1"
|
||||
name="quantity"
|
||||
type="number"
|
||||
value="2"
|
||||
|
@ -108998,6 +108999,7 @@ exports[`Storyshots Views / Orders / Order draft default 1`] = `
|
|||
<input
|
||||
aria-invalid="false"
|
||||
class="MuiInputBase-input-id MuiOutlinedInput-input-id"
|
||||
min="1"
|
||||
name="quantity"
|
||||
type="number"
|
||||
value="2"
|
||||
|
@ -109911,6 +109913,7 @@ exports[`Storyshots Views / Orders / Order draft no user permissions 1`] = `
|
|||
<input
|
||||
aria-invalid="false"
|
||||
class="MuiInputBase-input-id MuiOutlinedInput-input-id"
|
||||
min="1"
|
||||
name="quantity"
|
||||
type="number"
|
||||
value="2"
|
||||
|
@ -110015,6 +110018,7 @@ exports[`Storyshots Views / Orders / Order draft no user permissions 1`] = `
|
|||
<input
|
||||
aria-invalid="false"
|
||||
class="MuiInputBase-input-id MuiOutlinedInput-input-id"
|
||||
min="1"
|
||||
name="quantity"
|
||||
type="number"
|
||||
value="2"
|
||||
|
|
Loading…
Reference in a new issue