Skip to content

Commit c889eff

Browse files
Merge pull request #116 from OneBusAway/fix/disable-search-when-empty
fix: prevent empty search submissions and disable button accordingly
2 parents 2a8f3a5 + 0d79b53 commit c889eff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/search/SearchField.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
}
1818
1919
const onHandleSearch = (event) => {
20+
if (!value) {
21+
return;
22+
}
2023
if (event.key === 'Enter' || typeof event.key === 'undefined') {
2124
handleSearch();
2225
}
@@ -57,7 +60,8 @@
5760
<button
5861
type="button"
5962
on:click={onHandleSearch}
60-
class="rotate-rtl relative -ml-px inline-flex items-center gap-x-1.5 rounded-r-md px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 dark:text-gray-300 dark:hover:text-gray-900"
63+
disabled={!value}
64+
class="rotate-rtl relative -ml-px inline-flex items-center gap-x-1.5 rounded-r-md px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 disabled:cursor-not-allowed dark:text-gray-300 dark:hover:text-gray-900"
6165
>
6266
<svg
6367
xmlns="http://www.w3.org/2000/svg"

0 commit comments

Comments
 (0)