Skip to content

Commit

Permalink
modal pane appears on search by pressing enter
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunsinghofficial committed Aug 30, 2024
1 parent b8a3f29 commit 9e4dffa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/components/search/SearchResults.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let searchResults = [];
export let searchResults = null;
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
Expand All @@ -19,7 +19,7 @@
<h2 class="mb-4 text-xl font-bold">Search Results</h2>

<h3 class="mb-2 text-lg font-semibold">Stops</h3>
{#if searchResults.stopSearchResults && searchResults.stopSearchResults.list && searchResults.stopSearchResults.list.length > 0}
{#if searchResults?.stopSearchResults?.list?.length > 0}
<ul>
{#each searchResults.stopSearchResults.list as stop}
<li>
Expand All @@ -34,7 +34,7 @@
{/if}

<h3 class="mt-4 mb-2 text-lg font-semibold">Routes</h3>
{#if searchResults.routeSearchResults && searchResults.routeSearchResults.list && searchResults.routeSearchResults.list.length > 0}
{#if searchResults?.routeSearchResults?.list?.length > 0}
<ul>
{#each searchResults.routeSearchResults.list as route}
<li>
Expand Down
8 changes: 3 additions & 5 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let selectedRoute = null;
let showRouteMap = false;
let showAllStops = false;
let searchResults = [];
let searchResults = null;
function stopSelected(event) {
stop = event.detail.stop;
Expand Down Expand Up @@ -59,9 +59,7 @@
}
</script>

<Header
on:searchResults={handleSearch}
/>
<Header on:searchResults={handleSearch} />

{#if stop}
<ModalPane on:close={closePane}>
Expand All @@ -75,7 +73,7 @@
</ModalPane>
{/if}

{#if searchResults && searchResults.length > 0}
{#if searchResults && (searchResults.stopSearchResults?.list?.length > 0 || searchResults.routeSearchResults?.list?.length > 0)}
<ModalPane on:close={closeModal}>
<SearchResults {searchResults} />
</ModalPane>
Expand Down

0 comments on commit 9e4dffa

Please sign in to comment.