From 54605c838beb2671332d0a0135a10099bb791c25 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 22 Oct 2020 23:48:17 +0300 Subject: [PATCH] set customName only on user input --- edit/edit.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/edit/edit.js b/edit/edit.js index a9ffaa0e..7a4bbb2e 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -84,7 +84,7 @@ lazyInit(); nameEl.placeholder = t(usercss ? 'usercssEditorNamePlaceholder' : 'styleMissingName'); nameEl.title = isCustomName ? t('customNameHint') : ''; nameEl.addEventListener('input', () => { - updateName(); + updateName(true); resetEl.hidden = false; }); resetEl.hidden = !style.customName; @@ -95,7 +95,7 @@ lazyInit(); // trying to make it undoable via Ctrl-Z if (!document.execCommand('insertText', false, style.name)) { nameEl.value = style.name; - updateName(); + updateName(true); } style.customName = null; // to delete it from db resetEl.hidden = true; @@ -213,11 +213,13 @@ lazyInit(); editor.updateLivePreview(); } - function updateName() { + function updateName(isUserInput) { if (!editor) return; - const {value} = $('#name'); - dirty.modify('name', style[nameTarget] || style.name, value); - style[nameTarget] = value; + if (isUserInput) { + const {value} = $('#name'); + dirty.modify('name', style[nameTarget] || style.name, value); + style[nameTarget] = value; + } updateTitle({}); }