File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
packages/react-notion-x/src Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,8 @@ export const Search: React.FC<{
8787 search ?: SearchNotionFn
8888 title ?: React . ReactNode
8989} > = ( { block, search, title = 'Search' } ) => {
90- const { searchNotion, rootPageId, isShowingSearch } = useNotionContext ( )
90+ const { searchNotion, rootPageId, isShowingSearch, onHideSearch } =
91+ useNotionContext ( )
9192 const onSearchNotion = search || searchNotion
9293
9394 const [ isSearchOpen , setIsSearchOpen ] = React . useState ( isShowingSearch )
@@ -101,6 +102,9 @@ export const Search: React.FC<{
101102
102103 const onCloseSearch = React . useCallback ( ( ) => {
103104 setIsSearchOpen ( false )
105+ if ( onHideSearch ) {
106+ onHideSearch ( )
107+ }
104108 } , [ ] )
105109
106110 useHotkeys ( 'cmd+p' , ( event ) => {
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export interface NotionContext {
2121 mapImageUrl : MapImageUrlFn
2222 searchNotion ?: SearchNotionFn
2323 isShowingSearch ?: boolean
24+ onHideSearch ?: ( ) => void
2425
2526 rootPageId ?: string
2627 rootDomain ?: string
@@ -49,6 +50,7 @@ export interface PartialNotionContext {
4950 mapImageUrl ?: MapImageUrlFn
5051 searchNotion ?: SearchNotionFn
5152 isShowingSearch ?: boolean
53+ onHideSearch ?: ( ) => void
5254
5355 rootPageId ?: string
5456 rootDomain ?: string
@@ -151,6 +153,7 @@ const defaultNotionContext: NotionContext = {
151153 mapImageUrl : defaultMapImageUrl ,
152154 searchNotion : null ,
153155 isShowingSearch : false ,
156+ onHideSearch : null ,
154157
155158 fullPage : false ,
156159 darkMode : false ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export const NotionRenderer: React.FC<{
1919 mapImageUrl ?: MapImageUrlFn
2020 searchNotion ?: SearchNotionFn
2121 isShowingSearch ?: boolean
22+ onHideSearch ?: ( ) => void
2223
2324 rootPageId ?: string
2425 rootDomain ?: string
@@ -62,6 +63,7 @@ export const NotionRenderer: React.FC<{
6263 mapImageUrl,
6364 searchNotion,
6465 isShowingSearch,
66+ onHideSearch,
6567 fullPage,
6668 rootPageId,
6769 rootDomain,
@@ -97,6 +99,7 @@ export const NotionRenderer: React.FC<{
9799 mapImageUrl = { mapImageUrl }
98100 searchNotion = { searchNotion }
99101 isShowingSearch = { isShowingSearch }
102+ onHideSearch = { onHideSearch }
100103 fullPage = { fullPage }
101104 rootPageId = { rootPageId }
102105 rootDomain = { rootDomain }
You can’t perform that action at this time.
0 commit comments