@@ -26,6 +26,16 @@ const [product, module] = Astro.url.pathname.split("/").filter(Boolean);
2626 style =" border-color: var(--sl-color-hairline-light); background: var(--sl-color-bg-sidebar); color: var(--sl-color-text);"
2727 />
2828</div >
29+
30+ <!-- No Results Message -->
31+ <div id =" no-results-message" class =" p-4 text-center rounded-md my-2 border" style =" display: none; background-color: var(--sl-color-bg-sidebar); border-color: var(--sl-color-hairline-light);" >
32+ <p class =" mb-1 font-semibold text-sm" style =" color: var(--sl-color-text);" >No results found</p >
33+ <p class =" m-0 text-xs" style =" color: var(--sl-color-text-accent);" >
34+ Try a different search term, or
35+ <button id =" global-search-link" class =" underline cursor-pointer" style =" color: var(--sl-color-accent); background: none; border: none; padding: 0; font: inherit;" >use our global search</button >.
36+ </p >
37+ </div >
38+
2939<Default ><slot /></Default >
3040
3141<script >
@@ -42,7 +52,8 @@ const [product, module] = Astro.url.pathname.split("/").filter(Boolean);
4252 listItems: 'li',
4353 detailsGroups: 'details',
4454 links: 'a',
45- summaries: 'summary'
55+ summaries: 'summary',
56+ noResultsMessage: '#no-results-message'
4657 } as const;
4758
4859
@@ -117,6 +128,12 @@ const [product, module] = Astro.url.pathname.split("/").filter(Boolean);
117128
118129 allItems.forEach(item => toggleItemVisibility(item as HTMLElement, true));
119130 allGroups.forEach(group => toggleItemVisibility(group as HTMLElement, true));
131+
132+ // Hide no results message
133+ const noResultsMessage = document.querySelector(SELECTORS.noResultsMessage) as HTMLElement;
134+ if (noResultsMessage) {
135+ noResultsMessage.style.display = 'none';
136+ }
120137 }
121138
122139 /**
@@ -206,6 +223,35 @@ const [product, module] = Astro.url.pathname.split("/").filter(Boolean);
206223 toggleItemVisibility(group as HTMLElement, hasVisibleChildren);
207224 }
208225 });
226+
227+ // Check if any items are visible and show/hide no results message
228+ const visibleItems = sidebarContent.querySelectorAll('li:not([style*="display: none"])');
229+ const noResultsMessage = document.querySelector(SELECTORS.noResultsMessage) as HTMLElement;
230+ if (noResultsMessage) {
231+ noResultsMessage.style.display = visibleItems.length === 0 ? 'block' : 'none';
232+
233+ // Set up global search link click handler
234+ if (visibleItems.length === 0) {
235+ const globalSearchLink = noResultsMessage.querySelector('#global-search-link') as HTMLButtonElement;
236+ if (globalSearchLink) {
237+ globalSearchLink.onclick = () => {
238+ // Trigger DocSearch modal and pass the current query
239+ const docSearchButton = document.querySelector('#docsearch button') as HTMLButtonElement;
240+ if (docSearchButton) {
241+ docSearchButton.click();
242+ // Wait for modal to open and set the search query
243+ setTimeout(() => {
244+ const docSearchInput = document.querySelector('#docsearch-input') as HTMLInputElement;
245+ if (docSearchInput) {
246+ docSearchInput.value = query;
247+ docSearchInput.dispatchEvent(new Event('input', { bubbles: true }));
248+ }
249+ }, 100);
250+ }
251+ };
252+ }
253+ }
254+ }
209255 }
210256
211257 // Initialize search functionality when DOM is ready
@@ -221,6 +267,7 @@ const [product, module] = Astro.url.pathname.split("/").filter(Boolean);
221267 --tw-ring-color: var(--sl-color-accent);
222268 }
223269
270+
224271 :root {
225272 .sidebar-content {
226273 --sl-color-hairline-light: #cacaca !important;
0 commit comments