FIX: Context menu not appearing in Firefox (#154)
This commit is contained in:
parent
7d943be7b2
commit
3cf316fb62
|
@ -85,12 +85,25 @@ export default class AiHelperContextMenu extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
selectionChanged(event) {
|
selectionChanged() {
|
||||||
if (!event.target.activeElement.classList.contains("d-editor-input")) {
|
if (document.activeElement !== this._dEditorInput) {
|
||||||
return;
|
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) {
|
if (this.loading) {
|
||||||
// prevent accidentally closing context menu while results loading
|
// prevent accidentally closing context menu while results loading
|
||||||
return;
|
return;
|
||||||
|
@ -100,7 +113,6 @@ export default class AiHelperContextMenu extends Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectedText = event.target.getSelection().toString();
|
|
||||||
this._onSelectionChanged();
|
this._onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue