File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,14 +83,18 @@ export function DocSearch({
8383 ) . current ;
8484
8585 const saveRecentSearch = React . useCallback (
86- function saveRecentSearch ( item : StoredDocSearchHit ) {
86+ function saveRecentSearch ( item : InternalDocSearchHit ) {
87+ // We don't store `content` record, but their parent if available.
88+ const search = item . type === 'content' ? item . __docsearch_parent : item ;
89+
8790 // We save the recent search only if it's not favorited.
8891 if (
92+ search &&
8993 favoriteSearches
9094 . getAll ( )
91- . findIndex ( search => search . objectID === item . objectID ) === - 1
95+ . findIndex ( x => x . objectID === search . objectID ) === - 1
9296 ) {
93- recentSearches . add ( item ) ;
97+ recentSearches . add ( search ) ;
9498 }
9599 } ,
96100 [ favoriteSearches , recentSearches ]
Original file line number Diff line number Diff line change @@ -61,10 +61,6 @@ export function createStoredSearches<TItem extends StoredDocSearchHit>({
6161 ...hit
6262 } = ( item as unknown ) as DocSearchHit ;
6363
64- if ( hit . type === 'content' ) {
65- return ;
66- }
67-
6864 const isQueryAlreadySaved = items . findIndex (
6965 x => x . objectID === hit . objectID
7066 ) ;
You can’t perform that action at this time.
0 commit comments