question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not type any text in TextField

See original GitHub issue

With below code, i cannot type anything on the textfield. I mean to say nothing gets type in the textfield. Autocomplete works though. Why is it not showing the text i have typed?

What might be the reason for this issue? Have i done somewhere mistake?

import React, { Component } from 'react';
import _ from 'lodash';

import { connect } from 'react-redux';
import { Field, reduxForm } from 'redux-form';

import {
    AutoComplete as MUIAutoComplete, MenuItem,
    FlatButton, RaisedButton,
 } from 'material-ui';

import {
  AutoComplete,
  TextField
} from 'redux-form-material-ui';

const validate = values => {
  const errors = {};
  const requiredFields = ['deviceName', 'deviceIcon', 'deviceTimeout'];
  requiredFields.forEach(field => {
    if (!values[field]) {
      errors[field] = 'Required';
    }
});
  return errors;
};

class DeviceName extends Component {

  handleSubmit = (e) => {
      e.preventDefault();
      this.props.handleNext();
  }

  render() {
      const {
          handleSubmit,
          fetchIcon,
          stepIndex,
          handlePrev,
          pristine,
          submitting
      } = this.props;
      const listOfIcon = _.map(fetchIcon.icons, (icon) => ({
                                text: icon.name,
                                id: icon.id,
                                value:
                                <MenuItem
                                  primaryText={icon.name}
                                  leftIcon={
                                          <i className="material-icons md-23">
                                              {icon.name}
                                          </i>
                                          }
                                />
                      }));
    return (
        <div className="device-name-form">
            <form>
                <div>
                    <Field
                        name="deviceName"
                        component={TextField}
                        floatingLabelStyle={{ color: '#1ab394' }}
                        hintText="Device Name"
                        onChange={(e) => this.setState({ deviceName: e.target.name })}
                    />
                </div>
                <div>
                    <Field
                        name="deviceIcon"
                        component={AutoComplete}
                        hintText="icon"
                        openOnFocus
                        filter={MUIAutoComplete.fuzzyFilter}
                        className="autocomplete"
                        dataSource={listOfIcon}
                        onNewRequest={(e) => { this.setState({ deviceIcon: e.id }); }}
                    />
                </div>
                <div>
                    <Field
                        name="deviceTimeout"
                        component={TextField}
                        floatingLabelStyle={{ color: '#1ab394' }}
                        hintText="Device Timeout"
                        ref="deviceTimeout" withRef
                        onChange={(e) => this.setState({ deviceTimeout: e.target.name })}
                    />
                </div>
                <div style={{ marginTop: 12 }}>
                  <FlatButton
                    label="Back"
                    className="back-btn"
                    onTouchTap={() => handlePrev()}
                    style={{ marginRight: 12 }}
                  />
                  <RaisedButton
                    label={stepIndex === 4 ? 'Finish' : 'Next'}
                    primary
                    disabled={pristine || submitting}
                    className="our-btn"
                    onTouchTap={(e) => handleSubmit(e)}
                  />
                </div>
            </form>
        </div>
    );
  }
}

const mapStateToProps = ({ fetchIcon }) => ({
    fetchIcon
});

const DeviceForm = reduxForm({
  form: 'DeviceForm',
  validate,
})(DeviceName);

export default connect(mapStateToProps)(DeviceForm);```

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12

github_iconTop GitHub Comments

14reactions
Tushantcommented, Oct 28, 2016

You can copy paste this reducer to see if it works or not. Just for your ease to know if your issue will solve by setting reducer or not. If not then we can further discuss.

import { reducer as reducerForm } from 'redux-form';

const rootReducer = combineReducers({
 form: reducerForm
});

export default rootReducer;

4reactions
zakdancescommented, Oct 28, 2016

@Tushant Looks like it’s working now with your suggestion. Thanks for the help. What was confusing me was the form key. It can’t be given a different name…it must be written as form. And there was no error message to offer a clue to my mistake.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't type in React input text field - Stack Overflow
Try logging this when you input the text field. It could be that this is not the Searcher component anymore. Thanks FaureHu -...
Read more >
Unable to enter text in TextField - SwiftUI preview
I'm trying out Xcode 12 (beta) and encountered an issue with TextField when viewing it in a live Preview. Although the view is...
Read more >
Fix: Can't Type into Text Fields on Some Browsers - Appuals
Press Windows key + R to open up a Run dialog box. Then, type “osk” and press Enter to open up the On-Screen...
Read more >
Unable to type in Input field issue in React [Solved] | bobbyhadz
To solve the issue of being unable to type in an input field in React, make sure to use the `defaultValue` prop instead...
Read more >
type - Cypress Documentation
The text to be typed into the DOM element. Text passed to .type() may include any of the special character sequences below. These...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found