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.

Modal & redux-form doesn't work : focus lose.

See original GitHub issue

Hey, I’m using Modal to show some Forms with redux-form. Everything is working good, but one thing have weird behavior : focus on fields after typing first char.

When user write the first char in any input (Semantic Input or html5 input), we loose focus on this same field.

I made an simple redux-form => working perfectly. I put this exactly same form inside simple modal => focus bug.

import React, { Component } from 'react'
import {Field, reduxForm} from "redux-form"
import {Modal,Button,Input,Form} from 'semantic-ui-react'


  customInput = ({icon, placeholder, input, label, type, meta: { touched, error, warning}}) => (
    <Form.Field>
      <label> {label} </label>
      <Input fluid value={input.value} onChange={input.onChange} type={type} placeholder={label}/>
      </Form.Field>
  )

const ModalForm = (props) => {
    <Modal
        on="click"
        trigger={<Button>ShowModal</Button>}>
        <Modal.Content>
          <Form onSubmit={props.handleSubmit}>
            <div>
              <label
                htmlFor="firstName"> firstName
              </label>
              <Field name="firstName" component={customInput}  />
            </div>
            <div>
              <label
                htmlFor="secondName"> lastName
              </label>
              <Field name="secondName" component={customInput}/>

            </div>
          </Form>
          </Modal.Content>
          <Modal.Actions>
            <button type="submit"> Submit </button>
            </Modal.Actions>
      </Modal>
)


export default reduxForm({
  form:'ModalForm',
  onSubmit: (values, dispatch, props) => {
    dispatch("")
  }
})(ModalForm)

In this example, my form is connected with my redux-store. It’s working, but there’s still focus issue. If I remove Modal => it’s working.

Thanks for your helps.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

Unable to focus form element on modal open with react-hook ...
I want to focus a form element as soon as a modal opens. Since react-hook-form does not provide a direct handle to the...
Read more >
Field - Redux Form
A function to call when the form field loses focus. It expects to either receive the React SyntheticEvent _or_ the current value of...
Read more >
Accessibility - React
Programmatically managing focus. Our React applications continuously modify the HTML DOM during runtime, sometimes leading to keyboard focus being lost or set ...
Read more >
Focus on next Input field on Enter in Redux Form-Reactjs
How focus the next field input in react native? ... How to set focus on an input field after rendering? In React ES6,...
Read more >
A complete guide to React refs - LogRocket Blog
React doesn't provide an easy way to do this, so we can use refs to ... So when you open the modal, you...
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