Skip to content

Commit d07d792

Browse files
committed
fix mouse click issue
1 parent cf06afa commit d07d792

File tree

1 file changed

+19
-4
lines changed
  • src/mentionPlugin/MentionSearch/MentionOption

1 file changed

+19
-4
lines changed

src/mentionPlugin/MentionSearch/MentionOption/index.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,25 @@ export default class MentionOption extends Component {
99

1010
constructor(props) {
1111
super(props);
12-
this.state = {};
12+
this.mouseDown = false;
1313
}
1414

15-
onMentionSelect = () => {
16-
this.props.onMentionSelect(this.props.mention);
15+
componentDidUpdate() {
16+
this.mouseDown = false;
17+
}
18+
19+
onMouseUp = () => {
20+
if (this.mouseDown) {
21+
this.mouseDown = false;
22+
this.props.onMentionSelect(this.props.mention);
23+
}
24+
};
25+
26+
onMouseDown = (event) => {
27+
// Note: important to avoid a content edit change
28+
event.preventDefault();
29+
30+
this.mouseDown = true;
1731
};
1832

1933
onMouseEnter = () => {
@@ -25,7 +39,8 @@ export default class MentionOption extends Component {
2539
return (
2640
<div
2741
className={ className }
28-
onClick={ this.onMentionSelect }
42+
onMouseDown={ this.onMouseDown }
43+
onMouseUp={ this.onMouseUp }
2944
onMouseEnter={ this.onMouseEnter }
3045
role="option"
3146
>

0 commit comments

Comments
 (0)