Fix "Uncaught (in promise) Error: window.getSelection() is null" error (#316)

* Fix "Uncaught (in promise) Error: window.getSelection() is null" error
This commit is contained in:
def00111 2022-03-02 13:15:15 +01:00 committed by GitHub
parent 3363fc90a3
commit 45f83116f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,7 +86,7 @@ const getSelectedText = () => {
const isInTextField = element.tagName === "INPUT" || element.tagName === "TEXTAREA";
const selectedText = isInTextField
? element.value.substring(element.selectionStart, element.selectionEnd)
: window.getSelection().toString();
: window.getSelection()?.toString() ?? "";
return selectedText;
};