diff --git a/static/images/SCALE/Dashboard/GlobalSearchDocs.png b/static/images/SCALE/Dashboard/GlobalSearchDocs.png index b2bdd992c5..51389a7c7a 100644 Binary files a/static/images/SCALE/Dashboard/GlobalSearchDocs.png and b/static/images/SCALE/Dashboard/GlobalSearchDocs.png differ diff --git a/static/includes/UsingGlobalSearch.md b/static/includes/UsingGlobalSearch.md index 27536dd5f9..80586912f2 100644 --- a/static/includes/UsingGlobalSearch.md +++ b/static/includes/UsingGlobalSearch.md @@ -35,7 +35,6 @@ TrueNAS SCALE indicates the selected element with a glowing blue outline. Click **Search Documentation for <<*query*>>** to redirect the search to the TrueNAS Documentation Hub. TrueNAS SCALE opens a new browser tab to display documentation search results for the query. - {{< trueimage src="/images/SCALE/Dashboard/GlobalSearchDocs.png" alt="Search Documentation Results" id="Search Documentation Results" style="border:1px solid #0095d5" >}} Use this option to search for tutorials and UI reference documentation for the feature, or to look for further information when the entered search term does not find any matching UI elements. diff --git a/static/js/search-multi-site.js b/static/js/search-multi-site.js index f4499f28c6..0f69869163 100644 --- a/static/js/search-multi-site.js +++ b/static/js/search-multi-site.js @@ -102,6 +102,7 @@ class MultiSiteSearch { this.performSearch = this.performSearch.bind(this); this.loadMoreResults = this.loadMoreResults.bind(this); this.updateSearchIcon = this.updateSearchIcon.bind(this); + this.checkUrlQueryParameter = this.checkUrlQueryParameter.bind(this); this.init(); } @@ -238,6 +239,39 @@ class MultiSiteSearch { } catch (error) { // Could not pre-load docs index } + + // Check for URL query parameter and auto-execute search + this.checkUrlQueryParameter(); + } + + checkUrlQueryParameter() { + // Parse URL query parameters + const urlParams = new URLSearchParams(window.location.search); + const queryParam = urlParams.get('query'); + + if (queryParam && queryParam.trim() !== '') { + // Check if we're on the /search/ path and redirect to homepage with query + const currentPath = window.location.pathname; + if (currentPath === '/search/' || currentPath === '/search') { + // Redirect to homepage with query parameter preserved + window.location.href = `/${window.location.search}`; + return; + } + + // Open the modal + this.openModal(); + + // Set the search input value + const searchInput = document.getElementById('search-input-enhanced'); + if (searchInput) { + searchInput.value = queryParam.trim(); + } + + // Wait a short moment for modal to fully render, then perform search + setTimeout(() => { + this.performSearch(); + }, 200); + } } async loadIndex(siteKey) {