Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Typeahead.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
/** Set to `true` to re-focus the input after selecting a result */
export let focusAfterSelect = false;

/** Set to `true` to only show results when the input is focused */
/**
* Set to `true` to only show results when the input is focused
* @deprecated Focus is now always required to show results. This prop has no effect and will be removed in a future version.
*/
export let showDropdownOnFocus = false;

/** Set to `true` for all results to be shown when an empty input is focused */
Expand Down Expand Up @@ -150,10 +153,7 @@
.filter((result) => !filter(result.original))
.map((result) => ({ ...result, disabled: disable(result.original) }));
$: resultsId = results.map((result) => extract(result.original)).join("");
$: showResults = !hideDropdown && results.length > 0;
$: if (showDropdownOnFocus) {
showResults = showResults && isFocused;
}
$: showResults = !hideDropdown && results.length > 0 && isFocused;
$: if (isFocused && showAllResultsOnFocus && value.length === 0) {
results = data
.filter((datum) => !filter(datum))
Expand Down Expand Up @@ -205,9 +205,9 @@
on:focus
on:focus={() => {
open();
isFocused = true;
if (showDropdownOnFocus || showAllResultsOnFocus) {
showResults = true;
isFocused = true;
}
}}
on:clear
Expand Down