Last active
August 29, 2015 14:16
-
-
Save averyvery/3dd98f4ed378018164d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.disable-focus-styles *:focus { | |
outline: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = React.createClass({ | |
getInitialState() { | |
return { | |
usingMouse : false, | |
focusedOnElement : false | |
} | |
}, | |
_setUsingMouse(usingMouse) { | |
this.setState({usingMouse: usingMouse}) | |
}, | |
_setFocus(focused) { | |
this.setState({focusedOnElement: focused}) | |
}, | |
_userHasClicked() { | |
return this.state.usingMouse && this.state.focusedOnElement | |
}, | |
render() { | |
const className = this._userHasClicked() ? 'disable-focus-styles' : '' | |
return ( | |
<div className={className} | |
onKeyDown={this._setUsingMouse.bind(this, false)} | |
onMouseDown={this._setUsingMouse.bind(this, true)} | |
onFocus={this._setFocus.bind(this, true)} | |
onBlur={this._setFocus.bind(this, false)}> | |
<Nav/> | |
<RouteHandler {...this.props} /> | |
</div> | |
) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment