From 639d665639cb3002ac045d904714e58eb848b9a5 Mon Sep 17 00:00:00 2001 From: Shrey Dubey <53302612+shrey@users.noreply.github.com> Date: Thu, 11 Jun 2020 01:25:39 +0530 Subject: [PATCH] [EuiFieldNumber] Added `any` as a `step` option (#3562) --- CHANGELOG.md | 1 + src-docs/src/views/form_controls/field_number.js | 3 +-- src/components/form/field_number/field_number.tsx | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef7779bd76..dba081fcfe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Converted `EuiOverlayMask` to be a React functional component ([#3555](https://github.com/elastic/eui/pull/3555)) - Changed `responsive` and `max` behavior of `EuiBreadcrumbs` to always display collapsed items in popover [#3578](https://github.com/elastic/eui/pull/3578)) - Added `BREAKPOINTS` and `getBreakpoint` utilities [#3578](https://github.com/elastic/eui/pull/3578)) +- Added `'any'` option to the `step` prop of the `EuiFieldNumber` ([#3562](https://github.com/elastic/eui/pull/3562)) **Bug fixes** diff --git a/src-docs/src/views/form_controls/field_number.js b/src-docs/src/views/form_controls/field_number.js index 3ab94dab743..95ce6813838 100644 --- a/src-docs/src/views/form_controls/field_number.js +++ b/src-docs/src/views/form_controls/field_number.js @@ -7,8 +7,7 @@ export default () => { const [value, setValue] = useState(''); const onChange = e => { - const sanitizedValue = parseInt(e.target.value, 10); - setValue(isNaN(sanitizedValue) ? '' : sanitizedValue); + setValue(e.target.value); }; return ( diff --git a/src/components/form/field_number/field_number.tsx b/src/components/form/field_number/field_number.tsx index 3a7247ad77b..8c407ee9e74 100644 --- a/src/components/form/field_number/field_number.tsx +++ b/src/components/form/field_number/field_number.tsx @@ -39,7 +39,12 @@ export type EuiFieldNumberProps = InputHTMLAttributes & readOnly?: boolean; min?: number; max?: number; - step?: number; + /** + * Specifies the granularity that the value must adhere to. + * Accepts a `number` or the string `'any'` for no stepping to allow for any value. + * Defaults to `1` + */ + step?: number | 'any'; inputRef?: Ref; /**