Skip to content

Commit

Permalink
fix: show "No matches found" when palette has no matching items
Browse files Browse the repository at this point in the history
  • Loading branch information
bajrangCoder committed Dec 19, 2024
1 parent 1fbf104 commit 89c5f23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 14 additions & 6 deletions src/components/inputhints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export default function inputhints($input, hints, onSelect) {
const action = $el.getAttribute("action");
if (action !== "hint") return;
const value = $el.getAttribute("value");
if (!value) return;
if (!value) {
onblur();
return;
}
$input.value = $el.textContent;
if (onSelect) onSelect(value);
preventUpdate = false;
Expand Down Expand Up @@ -304,14 +307,19 @@ export default function inputhints($input, hints, onSelect) {
const end = offset + LIMIT;
const list = hints.slice(offset, end);
let scrollTop = $ul.scrollTop;
if (!list.length) return;
//if (!list.length) return;

$ul.remove();
if (!page) {
scrollTop = 0;
$ul.content = list.map((hint) => <Hint hint={hint} />);

if (!list.length) {
$ul.content = [<Hint hint={{ value: "", text: "No matches found" }} />];
} else {
$ul.append(...list.map((hint) => <Hint hint={hint} />));
if (!page) {
scrollTop = 0;
$ul.content = list.map((hint) => <Hint hint={hint} />);
} else {
$ul.append(...list.map((hint) => <Hint hint={hint} />));
}
}
app.append($ul);
$ul.scrollTop = scrollTop;
Expand Down
8 changes: 4 additions & 4 deletions src/components/inputhints/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../styles/mixins.scss';
@import "../../styles/mixins.scss";

#hints {
position: fixed;
Expand Down Expand Up @@ -29,8 +29,8 @@
border-radius: 4px;
}

[data-action='hint'],
[action='hint'] {
[data-action="hint"],
[action="hint"] {
font-size: 0.9rem;
min-height: 30px;
height: fit-content;
Expand Down Expand Up @@ -88,4 +88,4 @@
&:empty {
display: none;
}
}
}

0 comments on commit 89c5f23

Please sign in to comment.