remote-browser: hitting a letter to select a file based on its name was looping on the first two matches only

This commit is contained in:
jean-emmanuel 2019-04-18 17:51:41 +02:00
parent fa32803776
commit b65d7ecb0f
2 changed files with 16 additions and 3 deletions

View file

@ -4,6 +4,7 @@
- bug fixes
- bottom horizontal scrollbar not responding on small screens
- remote file browser: hitting a letter to select a file based on its name was looping on the first two matches only
- widgets
- `logScale` can be set to a number to use a logarithm base different from the default
- knob: `compact` mode is back

View file

@ -245,14 +245,26 @@ module.exports = {
list.childNodes[0].firstElementChild.checked = true
submit()
} else if (e.key.length === 1) {
var letter = e.key.toLowerCase()
var letter = e.key.toLowerCase(),
current = DOM.get(list, ':checked')[0],
minIndex = -1,
index = -1
if (current) minIndex = DOM.index(current.parentNode)
for (let i in files) {
if (files[i].name[0].toLowerCase() === letter && !list.childNodes[i].firstElementChild.checked) {
list.childNodes[i].firstElementChild.click()
list.childNodes[i].firstElementChild.focus()
if (index === -1) index = i
if (minIndex !== -1 && i < minIndex) continue
index = i
break
}
}
if (index !== -1) {
list.childNodes[index].firstElementChild.click()
list.childNodes[index].firstElementChild.focus()
}
}
}
function keyUpHandler(e){