Skip to content

Commit

Permalink
[EnhancedButton] Fix not setting focus when keyboardFocused prop set
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantemple committed May 10, 2016
1 parent f35eed0 commit dd1a60f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/internal/EnhancedButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {Component, PropTypes} from 'react';
import ReactDOM from 'react-dom';
import {createChildFragment} from '../utils/childUtils';
import Events from '../utils/events';
import keycode from 'keycode';
Expand Down Expand Up @@ -94,6 +95,10 @@ class EnhancedButton extends Component {
componentDidMount() {
injectStyle();
listenForTabPresses();
if (this.state.isKeyboardFocused) {
this.refs.enhancedButton.focus();
this.props.onKeyboardFocus(null, true);
}
}

componentWillReceiveProps(nextProps) {
Expand Down Expand Up @@ -304,6 +309,7 @@ class EnhancedButton extends Component {
const buttonProps = {
...other,
style: prepareStyles(mergedStyles),
ref: 'enhancedButton',
disabled: disabled,
onBlur: this.handleBlur,
onClick: this.handleClick,
Expand Down

0 comments on commit dd1a60f

Please sign in to comment.