Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: TextField.js Bug: `value` attribute missing from Tag

jkilbride free asked 6 years ago


In the TextField.js component, the value attribute is missing from the Tag in the render method:
<Tag
 {...attributes}
 id={id}
 className={classes}
 ref={el => { this.inputElRef = el; }}
 placeholder={hint}
 onBlur={this.onBlur}
 onChange={this.onChange}
 onFocus={this.onFocus}
 />
It is NOT included in the {...attributes}spread operator. Therefore, the value of the text control is never updated when setState is called. For updates to work, the Tag should be changed to this:
<Tag
 {...attributes}
 id={id}
 className={classes}
 ref={el => { this.inputElRef = el; }}
 placeholder={hint}
 value={this.state.innerValue}     <---- Add value attribute to control
 onBlur={this.onBlur}
 onChange={this.onChange}
 onFocus={this.onFocus}
 />
I have tested this locally by copying the source for the Input and TextField components into my project and making this change. Without the change, setState does not work. With the change, it does.  

Jakub Strebeyko staff answered 6 years ago


Hey jkilbride, Thanks for taking time and reaching out with this! Fix will be included in the next release. With Best Regards, Kuba

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: No
Tags