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<{
87
87
search ?: SearchNotionFn
88
88
title ?: React . ReactNode
89
89
} > = ( { block, search, title = 'Search' } ) => {
90
- const { searchNotion, rootPageId, isShowingSearch } = useNotionContext ( )
90
+ const { searchNotion, rootPageId, isShowingSearch, onHideSearch } =
91
+ useNotionContext ( )
91
92
const onSearchNotion = search || searchNotion
92
93
93
94
const [ isSearchOpen , setIsSearchOpen ] = React . useState ( isShowingSearch )
@@ -101,6 +102,9 @@ export const Search: React.FC<{
101
102
102
103
const onCloseSearch = React . useCallback ( ( ) => {
103
104
setIsSearchOpen ( false )
105
+ if ( onHideSearch ) {
106
+ onHideSearch ( )
107
+ }
104
108
} , [ ] )
105
109
106
110
useHotkeys ( 'cmd+p' , ( event ) => {
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export interface NotionContext {
21
21
mapImageUrl : MapImageUrlFn
22
22
searchNotion ?: SearchNotionFn
23
23
isShowingSearch ?: boolean
24
+ onHideSearch ?: ( ) => void
24
25
25
26
rootPageId ?: string
26
27
rootDomain ?: string
@@ -49,6 +50,7 @@ export interface PartialNotionContext {
49
50
mapImageUrl ?: MapImageUrlFn
50
51
searchNotion ?: SearchNotionFn
51
52
isShowingSearch ?: boolean
53
+ onHideSearch ?: ( ) => void
52
54
53
55
rootPageId ?: string
54
56
rootDomain ?: string
@@ -151,6 +153,7 @@ const defaultNotionContext: NotionContext = {
151
153
mapImageUrl : defaultMapImageUrl ,
152
154
searchNotion : null ,
153
155
isShowingSearch : false ,
156
+ onHideSearch : null ,
154
157
155
158
fullPage : false ,
156
159
darkMode : false ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export const NotionRenderer: React.FC<{
19
19
mapImageUrl ?: MapImageUrlFn
20
20
searchNotion ?: SearchNotionFn
21
21
isShowingSearch ?: boolean
22
+ onHideSearch ?: ( ) => void
22
23
23
24
rootPageId ?: string
24
25
rootDomain ?: string
@@ -62,6 +63,7 @@ export const NotionRenderer: React.FC<{
62
63
mapImageUrl,
63
64
searchNotion,
64
65
isShowingSearch,
66
+ onHideSearch,
65
67
fullPage,
66
68
rootPageId,
67
69
rootDomain,
@@ -97,6 +99,7 @@ export const NotionRenderer: React.FC<{
97
99
mapImageUrl = { mapImageUrl }
98
100
searchNotion = { searchNotion }
99
101
isShowingSearch = { isShowingSearch }
102
+ onHideSearch = { onHideSearch }
100
103
fullPage = { fullPage }
101
104
rootPageId = { rootPageId }
102
105
rootDomain = { rootDomain }
You can’t perform that action at this time.
0 commit comments