From 44228b2af6af2bfc1c6ea1c204425e75c9ce1da6 Mon Sep 17 00:00:00 2001 From: Ran Luo Date: Sat, 26 Oct 2019 23:17:58 +0800 Subject: [PATCH] fix #1489 (#1535) --- src/muya/lib/index.js | 8 ++------ src/renderer/components/editorWithTabs/editor.vue | 8 +++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/muya/lib/index.js b/src/muya/lib/index.js index adf4b0b7..81f086d1 100644 --- a/src/muya/lib/index.js +++ b/src/muya/lib/index.js @@ -325,14 +325,10 @@ class Muya { } selectAll () { - this.contentState.selectAll() - if (!this.hasFocus()) { - const activeElement = document.activeElement - if (activeElement.nodeName === 'INPUT') { - activeElement.select() - } + return } + this.contentState.selectAll() } /** diff --git a/src/renderer/components/editorWithTabs/editor.vue b/src/renderer/components/editorWithTabs/editor.vue index 5335c9d4..c2388dd8 100644 --- a/src/renderer/components/editorWithTabs/editor.vue +++ b/src/renderer/components/editorWithTabs/editor.vue @@ -817,8 +817,14 @@ export default { }, handleSelectAll () { - if (this.editor && !this.sourceCode) { + if (this.editor && !this.sourceCode && this.editor.hasFocus()) { this.editor.selectAll() + } else { + const activeElement = document.activeElement + const nodeName = activeElement.nodeName + if (nodeName === 'INPUT' || nodeName === 'TEXTAREA') { + activeElement.select() + } } },