mirror of
https://github.com/obsqrbtz/goose-highlighter.git
synced 2026-04-08 20:19:06 +03:00
fix: do not call save() on all keypresses in textboxes
This commit is contained in:
@@ -144,9 +144,11 @@ export class PopupController {
|
||||
this.updateListForm();
|
||||
});
|
||||
|
||||
listName.addEventListener('input', () => {
|
||||
this.lists[this.currentListIndex].name = listName.value;
|
||||
this.save();
|
||||
listName.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.lists[this.currentListIndex].name = listName.value;
|
||||
this.save();
|
||||
}
|
||||
});
|
||||
|
||||
listBg.addEventListener('input', () => {
|
||||
@@ -237,17 +239,30 @@ export class PopupController {
|
||||
|
||||
wordList.addEventListener('input', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
const index = +(target.dataset.wordEdit ?? target.dataset.bgEdit ?? target.dataset.fgEdit ?? -1);
|
||||
const index = +(target.dataset.bgEdit ?? target.dataset.fgEdit ?? -1);
|
||||
if (index === -1) return;
|
||||
|
||||
const word = this.lists[this.currentListIndex].words[index];
|
||||
if (target.dataset.wordEdit != null) word.wordStr = target.value;
|
||||
if (target.dataset.bgEdit != null) word.background = target.value;
|
||||
if (target.dataset.fgEdit != null) word.foreground = target.value;
|
||||
|
||||
this.save();
|
||||
});
|
||||
|
||||
wordList.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const target = e.target as HTMLInputElement;
|
||||
const index = +(target.dataset.wordEdit ?? -1);
|
||||
if (index === -1) return;
|
||||
|
||||
const word = this.lists[this.currentListIndex].words[index];
|
||||
if (target.dataset.wordEdit != null) {
|
||||
word.wordStr = target.value;
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let scrollTimeout: number;
|
||||
wordList.addEventListener('scroll', () => {
|
||||
if (scrollTimeout) return;
|
||||
@@ -473,6 +488,8 @@ export class PopupController {
|
||||
MessageService.sendToAllTabs({ type: 'EXCEPTIONS_LIST_UPDATED' });
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async updateGlobalToggleState(): Promise<void> {
|
||||
await StorageService.update('globalHighlightEnabled', this.globalHighlightEnabled);
|
||||
MessageService.sendToAllTabs({
|
||||
|
||||
Reference in New Issue
Block a user