Skip to content

Commit

Permalink
Merge pull request #116 from OneBusAway/fix/disable-search-when-empty
Browse files Browse the repository at this point in the history
fix: prevent empty search submissions and disable button accordingly
  • Loading branch information
aaronbrethorst authored Nov 13, 2024
2 parents 2a8f3a5 + 0d79b53 commit c889eff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/search/SearchField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
}
const onHandleSearch = (event) => {
if (!value) {
return;
}
if (event.key === 'Enter' || typeof event.key === 'undefined') {
handleSearch();
}
Expand Down Expand Up @@ -57,7 +60,8 @@
<button
type="button"
on:click={onHandleSearch}
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"
disabled={!value}
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"
>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down

0 comments on commit c889eff

Please sign in to comment.