diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a5b6a2e..d40dba1 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -5,6 +5,33 @@ import Section from '$lib/components/Section.svelte'; import Card from '$lib/components/Cards/Card.svelte'; + import { goto } from '$app/navigation'; + + // ICAO input state handler + let icao = $state(''); + $effect(() => { + const params = new URLSearchParams(); + + if (icao.length === 4) { + // If the ICAO code is exactly 4 characters long, add it to the URL parameters + if (icao) params.set('icao', icao); + + // This will trigger a navigation and reload the page data from the server + goto(`?${params.toString()}`, { + keepFocus: true, + replaceState: true, + noScroll: true + }); + } else { + // Otherwise, clear the parameter + goto(`?${params.toString()}`, { + keepFocus: true, + replaceState: true, + noScroll: true + }); + } + }); + let { children } = $props(); @@ -27,8 +54,6 @@