Skip to content

Commit

Permalink
FIX: Context menu not appearing in Firefox (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
keegangeorge committed Aug 23, 2023
1 parent 7d943be commit 3cf316f
Showing 1 changed file with 16 additions and 4 deletions.
Expand Up @@ -85,12 +85,25 @@ export default class AiHelperContextMenu extends Component {
}
@bind
selectionChanged(event) {
if (!event.target.activeElement.classList.contains("d-editor-input")) {
selectionChanged() {
if (document.activeElement !== this._dEditorInput) {
return;
}
if (window.getSelection().toString().length === 0) {
const canSelect = Boolean(
window.getSelection() &&
document.activeElement &&
document.activeElement.value
);
this.selectedText = canSelect
? document.activeElement.value.substring(
document.activeElement.selectionStart,
document.activeElement.selectionEnd
)
: "";
if (this.selectedText.length === 0) {
if (this.loading) {
// prevent accidentally closing context menu while results loading
return;
Expand All @@ -100,7 +113,6 @@ export default class AiHelperContextMenu extends Component {
return;
}
this.selectedText = event.target.getSelection().toString();
this._onSelectionChanged();
}
Expand Down

0 comments on commit 3cf316f

Please sign in to comment.