mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
💅 Implement 'step' feature for InputNumber component
This commit is contained in:
parent
7c77cb985f
commit
5fa45859c9
@ -29,6 +29,7 @@ function InputNumber(props) {
|
||||
onFocus={props.onFocus}
|
||||
placeholder={message}
|
||||
ref={props.inputRef}
|
||||
step={!Number.isNaN(Number(props.step)) ? Number(props.step) : 1}
|
||||
style={props.style}
|
||||
tabIndex={props.tabIndex}
|
||||
type="number"
|
||||
@ -49,6 +50,7 @@ InputNumber.defaultProps = {
|
||||
onBlur: () => {},
|
||||
onFocus: () => {},
|
||||
placeholder: 'app.utils.placeholder.defaultMessage',
|
||||
step: 1,
|
||||
style: {},
|
||||
tabIndex: '0',
|
||||
};
|
||||
@ -65,6 +67,7 @@ InputNumber.propTypes = {
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onFocus: PropTypes.func,
|
||||
placeholder: PropTypes.string,
|
||||
step: PropTypes.number,
|
||||
style: PropTypes.object,
|
||||
tabIndex: PropTypes.string,
|
||||
value: PropTypes.oneOfType([
|
||||
|
||||
@ -83,6 +83,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
|
||||
placeholder,
|
||||
style,
|
||||
tabIndex,
|
||||
step,
|
||||
value,
|
||||
} = this.props;
|
||||
const handleBlur = isFunction(onBlur) ? onBlur : this.handleBlur;
|
||||
@ -121,6 +122,7 @@ class InputNumberWithErrors extends React.Component { // eslint-disable-line rea
|
||||
placeholder={placeholder}
|
||||
style={inputStyle}
|
||||
tabIndex={tabIndex}
|
||||
step={step}
|
||||
value={value}
|
||||
/>
|
||||
<InputDescription
|
||||
@ -162,6 +164,7 @@ InputNumberWithErrors.defaultProps = {
|
||||
labelStyle: {},
|
||||
noErrorsDescription: false,
|
||||
placeholder: 'app.utils.placeholder.defaultMessage',
|
||||
step: 1,
|
||||
style: {},
|
||||
tabIndex: '0',
|
||||
validations: {},
|
||||
@ -209,6 +212,7 @@ InputNumberWithErrors.propTypes = {
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onFocus: PropTypes.func,
|
||||
placeholder: PropTypes.string,
|
||||
step: PropTypes.number,
|
||||
style: PropTypes.object,
|
||||
tabIndex: PropTypes.string,
|
||||
validations: PropTypes.object,
|
||||
|
||||
@ -72,7 +72,7 @@ class EditForm extends React.Component {
|
||||
name="sizeLimit"
|
||||
onChange={this.props.onChange}
|
||||
type="number"
|
||||
step="0.01"
|
||||
step={0.01}
|
||||
value={get(this.props.modifiedData, 'sizeLimit', 1) / 1000}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user