better up / down handling in FilterList (#232)

Better up/down handling in FilterList; fixes #230

Co-authored-by: Zef Hemel <zef@zef.me>
This commit is contained in:
Krzysztof Kowalczyk
2023-01-03 21:27:46 +01:00
committed by GitHub
co-authored by Zef Hemel
parent fdc08d893a
commit c3d5f4275e
2 changed files with 44 additions and 5 deletions
+5 -2
View File
@@ -150,9 +150,13 @@ export function FilterList({
updateFilter(text);
}}
onKeyUp={(view, e) => {
// This event is triggered after the key has been processed by CM already
if (onKeyPress) {
onKeyPress(e.key, view.state.sliceDoc());
}
return false;
}}
onKeyDown={(view, e) => {
switch (e.key) {
case "ArrowUp":
setSelectionOption(Math.max(0, selectedOption - 1));
@@ -176,8 +180,7 @@ export function FilterList({
return true;
case " ": {
const text = view.state.sliceDoc();
if (completePrefix && text === " ") {
console.log("Doing the complete thing");
if (completePrefix && text === "") {
setText(completePrefix);
updateFilter(completePrefix);
return true;