-
-
Notifications
You must be signed in to change notification settings - Fork 143
fixes plotly/dash-core_components#169 #277
Changes from 1 commit
2c59df5
1db86aa
44e4eea
71dc849
5c364f5
c3b3f06
d552406
ca10d31
099dac4
18b2846
ff47e95
110de52
0d1274b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,25 +25,29 @@ export default class Input extends Component { | |
setProps, | ||
type | ||
} = this.props; | ||
const {value} = this.state; | ||
//const {value} = this.state; | ||
return ( | ||
<input | ||
onChange={e => { | ||
this.setState({value: e.target.value}); | ||
if (setProps) { | ||
if (type === 'number') { | ||
setProps({value: Number(e.target.value)}); | ||
} | ||
else { | ||
setProps({value: e.target.value}); | ||
onBlur={ | ||
event => { | ||
this.setState({value: event.target.value}); | ||
if (setProps) { | ||
if (type === 'number') { | ||
setProps({value: Number(event.target.value)}); | ||
} | ||
else { | ||
setProps({value: event.target.value}); | ||
} | ||
} | ||
if (fireEvent) fireEvent({event: 'blur'}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain a bit about what this code is supposed to do? Is it really necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rejects the |
||
} | ||
onChange={ | ||
() => { | ||
if (fireEvent) fireEvent({event: 'change'}); | ||
} | ||
if (fireEvent) fireEvent({event: 'change'}); | ||
}} | ||
onBlur={() => { | ||
if (fireEvent) fireEvent({event: 'blur'}); | ||
}} | ||
value={value} | ||
} | ||
//value={value} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason that this doesn't work without removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it make sense, maybe it could work with another variable, i.e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I Added a prop |
||
{...omit(['fireEvent', 'setProps', 'value'], this.props)} | ||
/> | ||
); | ||
|
@@ -244,6 +248,11 @@ Input.propTypes = { | |
*/ | ||
step: PropTypes.string, | ||
|
||
/** | ||
* Sets the number of important digits. It can be the string any or a positive floating point number. If this attribute is not set to any, the default is zero. | ||
*/ | ||
precision: PropTypes.string, | ||
|
||
/** | ||
* Dash-assigned callback that gets fired when the input changes. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you comment this out, it will mean that a Dash user cannot provide the
value
prop to thedcc.Input
component (or rather, it will not do anything). You can see in theconstructor
of the class thatthis.state.value
is set toprops.value
, and below in<input />
, it gets set to the value attribute:<input value={value} />
.