Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiFieldNumber] Added any as a step option #3562

Merged
merged 9 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added conditional rendering of the title element in `EuiCallOut` to avoid usage of additional space caused by the rendered `<div>` element ([#3549](https://github.com/elastic/eui/pull/3549))
- Added 'any' option to the step prop of the `EuiFieldNumber`. ([#3562](https://github.com/elastic/eui/pull/3562))

**Bug fixes**

Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/form_controls/field_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -19,6 +18,7 @@ export default () => {
value={value}
onChange={e => onChange(e)}
aria-label="Use aria labels when no actual label is in use"
step={3}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not add a step like this as it could confuse consumers that this is the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I forgot to remove that, I was just testing it

/>
</DisplayToggles>
);
Expand Down
7 changes: 6 additions & 1 deletion src/components/form/field_number/field_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ export type EuiFieldNumberProps = InputHTMLAttributes<HTMLInputElement> &
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';
shrey marked this conversation as resolved.
Show resolved Hide resolved
inputRef?: Ref<HTMLInputElement>;

/**
Expand Down