I have an input with the disabled boolean propagated from the props. I've found that with that disabled variable being set, even when it's true I cannot type into the input. I can, however, type into the input if I hold the mouse down on it and keep it down as I type.
This happens when I render the component as both controlled and uncontrolled.
The only way to fix it is to either removing disabled or setting disabled={false} -- but I need it to be variabled.
This is my input:
class DashboardWidgetTitle extends React.Component {
constructor(props) {
super(props);
this.state = {};
this.state.title = props.widget.getTitle();
}
render () {
return <input className="title"
value={this.state.title}
disabled={!this.props.isEditMode}
onChange={this._onInputChange.bind(this)}/>
}
_onInputChange(e) {
logit("input change");
this.setState({title: e.target.value});
}
}
Thanks!
EDIT: Extra info --
- This is used in a widget within an implementation of ReactGridLayout.
- The component is rendered by a widget that is rendered by the implementation of react grid layout, the "dashboard". That Dashboard has
isEditModeas a state that's changed externally via a toggle in Angular (we use React within Angular). - If I switch tabs and come back, the focus remains. Otherwise whenever I type a letter, the input becomes unfocused.
- The input isn't disabled when it shouldn't be, it just has focusing issues -- however removing the
disabledattribute or setting it as a static variable, the issue doesn't remain. - When I switch the disabled toggle to be
isEditModerather than!isEditMode, everything works. It seems to be there's an onclick on the draggable/resizable portion of the ReactGridLayout that's causing some issues.
DashboardWidgetTitle<DashboardWidgetTitle widget={this.props.widget} isEditMode={this.props.isEditMode}/>theisEditModeis set 2 levels up as a state object. It isn't being changed.isEditModeis not being passed down correctly. I would log it's value on render. My guess is that it's undefined (not passed) and!undefinedistrue.disabledattribute at all when it shouldn't. The input does allow focus, in this case, just not a change. The weirdest part is I can get it to work if I type as I hold down the mouse on the input. I'm