Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7979934

Browse files
authored
Merge pull request #2999 from matrix-org/t3chguy/copied_tooltip
Close copy tooltip in edge cases correctly
2 parents db73e64 + e2476ac commit 7979934

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/views/dialogs/ShareDialog.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export default class ShareDialog extends React.Component {
114114
top: y,
115115
message: successful ? _t('Copied!') : _t('Failed to copy'),
116116
}, false);
117-
e.target.onmouseleave = close;
117+
// Drop a reference to this close handler for componentWillUnmount
118+
this.closeCopiedTooltip = e.target.onmouseleave = close;
118119
}
119120

120121
onLinkSpecificEventCheckboxClick() {
@@ -131,6 +132,12 @@ export default class ShareDialog extends React.Component {
131132
}
132133
}
133134

135+
componentWillUnmount() {
136+
// if the Copied tooltip is open then get rid of it, there are ways to close the modal which wouldn't close
137+
// the tooltip otherwise, such as pressing Escape or clicking X really quickly
138+
if (this.closeCopiedTooltip) this.closeCopiedTooltip();
139+
}
140+
134141
render() {
135142
let title;
136143
let matrixToUrl;

0 commit comments

Comments
 (0)