mirror of
https://github.com/eugeny/tabby
synced 2025-12-12 18:55:47 +00:00
allow directly editing items from the profile selector - fixes #6039
This commit is contained in:
@@ -27,7 +27,7 @@ export class SelectorModalComponent<T> {
|
||||
this.hasGroups = this.options.some(x => x.group)
|
||||
}
|
||||
|
||||
@HostListener('keyup', ['$event']) onKeyUp (event: KeyboardEvent): void {
|
||||
@HostListener('keydown', ['$event']) onKeyUp (event: KeyboardEvent): void {
|
||||
if (event.key === 'ArrowUp') {
|
||||
this.selectedIndex--
|
||||
event.preventDefault()
|
||||
@@ -42,6 +42,10 @@ export class SelectorModalComponent<T> {
|
||||
if (event.key === 'Escape') {
|
||||
this.close()
|
||||
}
|
||||
if (event.key === 'Backspace' && this.canEditSelected()) {
|
||||
this.filter = this.filteredOptions[this.selectedIndex].freeInputEquivalent!
|
||||
this.onFilterChange()
|
||||
}
|
||||
|
||||
this.selectedIndex = (this.selectedIndex + this.filteredOptions.length) % this.filteredOptions.length
|
||||
Array.from(this.itemChildren)[this.selectedIndex]?.nativeElement.scrollIntoView({
|
||||
@@ -85,6 +89,10 @@ export class SelectorModalComponent<T> {
|
||||
this.modalInstance.close(option.result)
|
||||
}
|
||||
|
||||
canEditSelected (): boolean {
|
||||
return !this.filter && !!this.filteredOptions[this.selectedIndex].freeInputEquivalent && this.options.some(x => x.freeInputPattern)
|
||||
}
|
||||
|
||||
close (): void {
|
||||
this.modalInstance.dismiss()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user