diff --git a/src/components/home.tsx b/src/components/home.tsx
index dd64f065e0ed9a..eddaec9dda8f1c 100644
--- a/src/components/home.tsx
+++ b/src/components/home.tsx
@@ -21,7 +21,7 @@ import {PlatformFilter} from './platformFilter';
export function Home() {
return (
-
+
diff --git a/src/components/search/index.tsx b/src/components/search/index.tsx
index a00b262652850a..553832d7937554 100644
--- a/src/components/search/index.tsx
+++ b/src/components/search/index.tsx
@@ -62,18 +62,50 @@ type Props = {
autoFocus?: boolean;
path?: string;
searchPlatforms?: string[];
+ showChatBot?: boolean;
+ useStoredSearchPlatforms?: boolean;
};
-export function Search({path, autoFocus, searchPlatforms = []}: Props) {
+const STORAGE_KEY = 'sentry-docs-search-platforms';
+
+export function Search({
+ path,
+ autoFocus,
+ searchPlatforms = [],
+ useStoredSearchPlatforms = true,
+}: Props) {
const ref = useRef
(null);
const [query, setQuery] = useState(``);
const [results, setResults] = useState([] as Result[]);
const [inputFocus, setInputFocus] = useState(false);
const [showOffsiteResults, setShowOffsiteResults] = useState(false);
const [loading, setLoading] = useState(true);
-
+ const [currentSearchPlatforms, setCurrentSearchPlatforms] = useState(searchPlatforms);
const pathname = usePathname();
+ // Load stored platforms on mount
+ useEffect(() => {
+ const storedPlatforms = localStorage.getItem(STORAGE_KEY) ?? '[]';
+ if (!storedPlatforms) {
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(searchPlatforms));
+ } else if (
+ storedPlatforms &&
+ searchPlatforms.length === 0 &&
+ useStoredSearchPlatforms
+ ) {
+ const platforms = JSON.parse(storedPlatforms);
+ setCurrentSearchPlatforms(platforms);
+ }
+ }, [useStoredSearchPlatforms, searchPlatforms]);
+
+ // Update stored platforms when they change
+ useEffect(() => {
+ if (searchPlatforms.length > 0) {
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(searchPlatforms));
+ setCurrentSearchPlatforms(searchPlatforms);
+ }
+ }, [searchPlatforms]);
+
const handleClickOutside = useCallback((ev: MouseEvent) => {
// don't close the search results if the user is clicking the expand button
if (
@@ -143,7 +175,7 @@ export function Search({path, autoFocus, searchPlatforms = []}: Props) {
inputQuery,
{
path,
- platforms: searchPlatforms.map(
+ platforms: currentSearchPlatforms.map(
platform => standardSDKSlug(platform)?.slug ?? ''
),
searchAllIndexes: showOffsiteResults,
@@ -163,7 +195,7 @@ export function Search({path, autoFocus, searchPlatforms = []}: Props) {
setResults(queryResults);
}
},
- [path, searchPlatforms, showOffsiteResults, loading]
+ [path, currentSearchPlatforms, showOffsiteResults, loading]
);
const totalHits = results.reduce((a, x) => a + x.hits.length, 0);