Skip to content

Commit 82ace1b

Browse files
committed
fix: selection tools window pops up when selecting blank content (#104)
1 parent 9da7b0a commit 82ace1b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content-script/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function prepareForSelectionTools() {
126126

127127
deleteToolbar()
128128
setTimeout(() => {
129-
const selection = window.getSelection()?.toString()
129+
const selection = window.getSelection()?.toString().trim()
130130
if (selection) {
131131
const inputElement = selectionElement.querySelector('input, textarea')
132132
let position
@@ -165,7 +165,7 @@ async function prepareForSelectionTools() {
165165
(e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA')
166166
) {
167167
setTimeout(() => {
168-
if (!window.getSelection()?.toString()) deleteToolbar()
168+
if (!window.getSelection()?.toString().trim()) deleteToolbar()
169169
})
170170
}
171171
})
@@ -183,7 +183,7 @@ async function prepareForSelectionToolsTouch() {
183183

184184
deleteToolbar()
185185
setTimeout(() => {
186-
const selection = window.getSelection()?.toString()
186+
const selection = window.getSelection()?.toString().trim()
187187
if (selection) {
188188
toolbarContainer = createElementAtPosition(
189189
e.changedTouches[0].pageX + 20,

0 commit comments

Comments
 (0)