1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-20 07:49:57 +00:00

fix(Tiptap): don't consume key events if no items (#1594)

This commit is contained in:
Tuur Martens 2023-02-03 15:21:29 +01:00 committed by GitHub
parent faa96c7705
commit a8e7fd52a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View file

@ -40,6 +40,9 @@ watch(items, () => {
}) })
function onKeyDown(event: KeyboardEvent) { function onKeyDown(event: KeyboardEvent) {
if (items.length === 0)
return false
if (event.key === 'ArrowUp') { if (event.key === 'ArrowUp') {
selectedIndex = ((selectedIndex + items.length) - 1) % items.length selectedIndex = ((selectedIndex + items.length) - 1) % items.length
return true return true

View file

@ -15,6 +15,9 @@ watch(items, () => {
}) })
function onKeyDown(event: KeyboardEvent) { function onKeyDown(event: KeyboardEvent) {
if (items.length === 0)
return false
if (event.key === 'ArrowUp') { if (event.key === 'ArrowUp') {
selectedIndex = ((selectedIndex + items.length) - 1) % items.length selectedIndex = ((selectedIndex + items.length) - 1) % items.length
return true return true

View file

@ -15,6 +15,9 @@ watch(items, () => {
}) })
function onKeyDown(event: KeyboardEvent) { function onKeyDown(event: KeyboardEvent) {
if (items.length === 0)
return false
if (event.key === 'ArrowUp') { if (event.key === 'ArrowUp') {
selectedIndex = ((selectedIndex + items.length) - 1) % items.length selectedIndex = ((selectedIndex + items.length) - 1) % items.length
return true return true