Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
### Bug fixes

- Fixed animation for Modal when being rendered asynchronously ([#2076](https://github.com/Shopify/polaris-react/pull/2076))
- Updated `TextField` `min` and `max` type from `number` to `number | string` to allow min/max dates ([#1991](https://github.com/Shopify/polaris-react/pull/1991))

### Documentation

Expand Down
13 changes: 8 additions & 5 deletions src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ export interface BaseProps {
step?: number;
/** Enable automatic completion by the browser */
autoComplete?: boolean | string;
/** Mimics the behavior of the native HTML attribute, limiting how high the spinner can increment the value */
max?: number;
/** Mimics the behavior of the native HTML attribute, limiting the maximum value */
max?: number | string;
/** Maximum character length for an input */
maxLength?: number;
/** Mimics the behavior of the native HTML attribute, limiting how low the spinner can decrement the value */
min?: number;
/** Mimics the behavior of the native HTML attribute, limiting the minimum value */
min?: number | string;
/** Minimum character length for an input */
minLength?: number;
/** A regular expression to check the value against */
Expand Down Expand Up @@ -432,7 +432,10 @@ class TextField extends React.PureComponent<CombinedProps, State> {
// step / value has.
const decimalPlaces = Math.max(dpl(numericValue), dpl(step));

const newValue = Math.min(max, Math.max(numericValue + steps * step, min));
const newValue = Math.min(
Number(max),
Math.max(numericValue + steps * step, Number(min)),
);
onChange(String(newValue.toFixed(decimalPlaces)), this.state.id);
};

Expand Down