Skip to content

Commit 03574ef

Browse files
authored
fix: show "No matches found" when palette has no matching items (#1110)
1 parent 1fbf104 commit 03574ef

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/components/inputhints/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ export default function inputhints($input, hints, onSelect) {
7070
const action = $el.getAttribute("action");
7171
if (action !== "hint") return;
7272
const value = $el.getAttribute("value");
73-
if (!value) return;
73+
if (!value) {
74+
onblur();
75+
return;
76+
}
7477
$input.value = $el.textContent;
7578
if (onSelect) onSelect(value);
7679
preventUpdate = false;
@@ -304,14 +307,19 @@ export default function inputhints($input, hints, onSelect) {
304307
const end = offset + LIMIT;
305308
const list = hints.slice(offset, end);
306309
let scrollTop = $ul.scrollTop;
307-
if (!list.length) return;
310+
//if (!list.length) return;
308311

309312
$ul.remove();
310-
if (!page) {
311-
scrollTop = 0;
312-
$ul.content = list.map((hint) => <Hint hint={hint} />);
313+
314+
if (!list.length) {
315+
$ul.content = [<Hint hint={{ value: "", text: "No matches found" }} />];
313316
} else {
314-
$ul.append(...list.map((hint) => <Hint hint={hint} />));
317+
if (!page) {
318+
scrollTop = 0;
319+
$ul.content = list.map((hint) => <Hint hint={hint} />);
320+
} else {
321+
$ul.append(...list.map((hint) => <Hint hint={hint} />));
322+
}
315323
}
316324
app.append($ul);
317325
$ul.scrollTop = scrollTop;

src/components/inputhints/style.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '../../styles/mixins.scss';
1+
@import "../../styles/mixins.scss";
22

33
#hints {
44
position: fixed;
@@ -29,8 +29,8 @@
2929
border-radius: 4px;
3030
}
3131

32-
[data-action='hint'],
33-
[action='hint'] {
32+
[data-action="hint"],
33+
[action="hint"] {
3434
font-size: 0.9rem;
3535
min-height: 30px;
3636
height: fit-content;
@@ -88,4 +88,4 @@
8888
&:empty {
8989
display: none;
9090
}
91-
}
91+
}

0 commit comments

Comments
 (0)