Skip to content

Commit

Permalink
Merge pull request #3 from vzvu3k6k/ignore-selection
Browse files Browse the repository at this point in the history
Don't toggle QuestionCard when you select text
  • Loading branch information
r7kamura authored Dec 5, 2016
2 parents 9f5af1e + 211d429 commit c1f4439
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ class QuestionCard extends React.Component {
constructor(...args) {
super(...args);
this.state = { hidden: true };
this.handleClick = this.handleClick.bind(this);
}

handleClick(event) {
if (!window.getSelection || window.getSelection().isCollapsed) {
this.setState({ hidden: !this.state.hidden });
}
}

render() {
return(
<div className="card card-clickable" onClick={(event) => { this.setState({ hidden: !this.state.hidden }) }}>
<div className="card card-clickable" onClick={this.handleClick}>
<div className="card-body">
Q. {this.props.question}
</div>
Expand Down

0 comments on commit c1f4439

Please sign in to comment.