feat(core/selector): PageUp/Down toogle at end of filteredOptions

This commit is contained in:
Clem 2023-08-17 17:58:41 +02:00
parent d354520910
commit ad3b03cb83

View file

@ -33,10 +33,11 @@ export class SelectorModalComponent<T> {
this.close()
} else if (this.filteredOptions.length > 0) {
if (event.key === 'PageUp' || event.key === 'ArrowUp' && event.metaKey) {
this.selectedIndex -= 10
this.selectedIndex -= Math.min(10, this.selectedIndex === 0 ? 1 : this.selectedIndex)
event.preventDefault()
} else if (event.key === 'PageDown' || event.key === 'ArrowDown' && event.metaKey) {
this.selectedIndex += 10
const newI = this.filteredOptions.length - this.selectedIndex - 1
this.selectedIndex += Math.min(10, newI === 0 ? 1 : newI)
event.preventDefault()
} else if (event.key === 'ArrowUp') {
this.selectedIndex--