diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ad18a7..861ae54c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - A bug where it says "(Failed to load)" when switching profiles +- A bug where searching in web app using iOS causes page to reload ### Changed diff --git a/playlet-lib/src/components/Web/PlayletWebServer/PlayletWebServer.bs b/playlet-lib/src/components/Web/PlayletWebServer/PlayletWebServer.bs index e99b7a6f..f32ed0c3 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/PlayletWebServer.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/PlayletWebServer.bs @@ -40,6 +40,8 @@ function SetupRoutes(server as object) #if DEBUG 'CORS is mostly for developing the web app server.UseRouter(new Http.CorsMiddleware()) + #else + server.UseRouter(new Http.CorsMiddleware("")) #end if if server.settings.WebSocketsEnabled server.UseRouter(new Http.WebSocketMiddleware()) diff --git a/playlet-lib/src/components/Web/WebServer/Middleware/CorsMiddleware.bs b/playlet-lib/src/components/Web/WebServer/Middleware/CorsMiddleware.bs index 769be517..c03f94cf 100644 --- a/playlet-lib/src/components/Web/WebServer/Middleware/CorsMiddleware.bs +++ b/playlet-lib/src/components/Web/WebServer/Middleware/CorsMiddleware.bs @@ -20,9 +20,17 @@ namespace Http request = context.request response = context.response - response.headers["Access-Control-Allow-Origin"] = m.origin - response.headers["Access-Control-Allow-Headers"] = m.headers - response.headers["Access-Control-Allow-Methods"] = m.methods + if not StringUtils.IsNullOrEmpty(m.origin) + response.headers["Access-Control-Allow-Origin"] = m.origin + end if + + if not StringUtils.IsNullOrEmpty(m.headers) + response.headers["Access-Control-Allow-Headers"] = m.headers + end if + + if not StringUtils.IsNullOrEmpty(m.methods) + response.headers["Access-Control-Allow-Methods"] = m.methods + end if if request.method = "OPTIONS" response.header_only = true diff --git a/playlet-web/src/lib/Screens/SearchScreen.svelte b/playlet-web/src/lib/Screens/SearchScreen.svelte index 7eb2bc71..cb2bdac5 100644 --- a/playlet-web/src/lib/Screens/SearchScreen.svelte +++ b/playlet-web/src/lib/Screens/SearchScreen.svelte @@ -99,6 +99,8 @@ try { isLoading = true; + // blur to hide the keyboard on mobile + searchBox.blur(); const response = await invidiousApi.search( searchBoxText, searchFilters, @@ -120,73 +122,76 @@
- -
{ - e.preventDefault(); - page = 1; - videos = []; - await searchVideos(""); - }} - > -
- { - // A delay before clearing the suggestions allows the user to click on a suggestion - // Clicking the suggestion will trigger the blur event immediately, and the search won't happen - setTimeout(() => { - suggestions = { suggestions: [] }; - }, 200); - }} - /> - -
-
- {searchFiltersLabel} - - - {#if suggestions.suggestions.length > 0} - - {/if} - +
+ +
+ {searchFiltersLabel} + + + {#if suggestions.suggestions.length > 0} + + {/if} + +
@@ -207,6 +212,7 @@ {#if !isLoading && videos.length > 0 && searchBoxText}