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

fix(Dropdown): fix crash when setting defaultOpen on a search dropdown #1005

Merged
merged 1 commit into from
Dec 9, 2016

Conversation

fracmak
Copy link
Member

@fracmak fracmak commented Dec 8, 2016

Because the this.open() call happens inside componentWillMount(), the search input hasn't been built yet and the this._search.focus() crashes. This simply moves the open call to a componentDidMount() function

}

componentDidMount() {
const { open } = this.state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because open() sets state, this results in setting state on mount which is an antipattern. We have a lint rule for this enabled, although, because it is indirect and abstracted away, it is not picking up on it.

I think we should instead add guarding logic where the focus() is called and only call it if there is a node present.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@levithomason levithomason merged commit c4cd2bc into Semantic-Org:master Dec 9, 2016
@levithomason
Copy link
Member

Thanks much!

@levithomason
Copy link
Member

Releasing now as semantic-ui-react@0.62.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants