Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set modal focus state before showing #104

Merged
merged 1 commit into from
Aug 19, 2016

Conversation

tyler-johnson
Copy link
Contributor

Hello,

I was having some issues with controlled inputs inside modals. When I would update the Modal after an input value changed, the input would suddenly lose focus. I managed to track this issue down to the Modal's focus state being set after the call to renderIntoSubtree(). This meant that the Modal wasn't be focused until the next render, when the input changed values.

Here is some React code to show what I mean:

import React from "react";
import {Modal,ModalBody} from "reactstrap";

class ModalWithInput extends React.Component {
  state = {};

  render() {
    return <Modal {...this.props}>
      <ModalBody>
        <input
          type="text"
          value={this.state.inputValue}
          onChange={(e) => this.setState({ inputValue: e.target.value })} />
      </ModalBody>
    </Modal>;
  }
}

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 09dabf8 on tyler-johnson:modal-focus-fix into 869e523 on reactstrap:master.

@eddywashere
Copy link
Member

Thanks @tyler-johnson, great find!

@eddywashere eddywashere merged commit a358233 into reactstrap:master Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants