Only show unbind note on custom presets

This commit is contained in:
redphx
2024-12-09 17:42:51 +07:00
parent 5381575048
commit d292bef5e7
4 changed files with 15 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ export class KeyboardShortcutsManagerDialog extends BaseProfileManagerDialog<Key
// private readonly LOG_TAG = 'KeyboardShortcutsManagerDialog';
protected $content: HTMLElement;
private $unbindNote: HTMLElement;
private readonly allKeyElements: BxKeyBindingButton[] = [];
protected readonly BLANK_PRESET_DATA: KeyboardShortcutPresetData = {
@@ -65,7 +66,10 @@ export class KeyboardShortcutsManagerDialog extends BaseProfileManagerDialog<Key
}
}
this.$content = CE('div', {}, $rows);
this.$content = CE('div', {},
this.$unbindNote = CE('i', { class: 'bx-mkb-note' }, t('right-click-to-unbind')),
$rows,
);
}
private onKeyChanged = (e: Event) => {
@@ -109,6 +113,9 @@ export class KeyboardShortcutsManagerDialog extends BaseProfileManagerDialog<Key
const isDefaultPreset = id <= 0;
this.updateButtonStates();
// Toggle unbind note
this.$unbindNote.classList.toggle('bx-gone', isDefaultPreset);
// Update buttons
for (const $elm of this.allKeyElements) {
const { action } = this.parseDataset($elm);