Skip to content

Commit

Permalink
Fix can't delete search input in CardBrowser after an initial search
Browse files Browse the repository at this point in the history
The DEL KeyEvent was previously declared to act as a keyboard shortcut
to delete the selected notes. After an initial search which registered
a search query entering DEL attempted to delete the current selected
notes which also resulted in another search(same input) being executed.

The fix registers the DEL keys as a delete notes shortcut ONLY if the
search box of the CardBrowser is not currently available(isIconified
returning true).
  • Loading branch information
lukstbit authored and BrayanDSO committed Aug 31, 2024
1 parent 83def3f commit e7eee16
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,16 @@ open class CardBrowser :
}
}
KeyEvent.KEYCODE_FORWARD_DEL, KeyEvent.KEYCODE_DEL -> {
Timber.i("Delete pressed - Delete Selected Note")
deleteSelectedNotes()
return true
if (searchView?.isIconified == false) {
Timber.i("Delete pressed - Search active, deleting character")
// the search box is available and could potentially receive input so handle the
// DEL as a simple text deletion and not as a keyboard shortcut
return false
} else {
Timber.i("Delete pressed - Delete Selected Note")
deleteSelectedNotes()
return true
}
}
KeyEvent.KEYCODE_F -> {
if (event.isCtrlPressed) {
Expand Down

0 comments on commit e7eee16

Please sign in to comment.