File tree 1 file changed +24
-1
lines changed 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,27 @@ const SearchModalNoteResultItem = ({
75
75
[ highlightMatchedTerm ]
76
76
)
77
77
78
+ const updateSelectedItemAndFocus = useCallback (
79
+ ( target , note , id ) => {
80
+ {
81
+ updateSelectedItem ( note , id )
82
+
83
+ setTimeout ( ( ) => {
84
+ target . scrollIntoView (
85
+ {
86
+ // todo: [komediruzecki-12/12/2020] Smooth looks nice, do we want instant (as now) or slowly auto scrolling to element
87
+ behavior : 'auto' ,
88
+ block : 'nearest' ,
89
+ inline : 'nearest' ,
90
+ } ,
91
+ 20
92
+ )
93
+ } )
94
+ }
95
+ } ,
96
+ [ updateSelectedItem ]
97
+ )
98
+
78
99
return (
79
100
< Container >
80
101
< MetaContainer onClick = { navigate } >
@@ -106,7 +127,9 @@ const SearchModalNoteResultItem = ({
106
127
selectedItemId == result . id ? 'search-result-selected' : ''
107
128
}
108
129
key = { getSearchResultKey ( note . _id , result . id ) }
109
- onClick = { ( ) => updateSelectedItem ( note , result . id ) }
130
+ onClick = { ( event : MouseEvent ) =>
131
+ updateSelectedItemAndFocus ( event . target , note , result . id )
132
+ }
110
133
onDoubleClick = { ( ) =>
111
134
navigateToEditorFocused (
112
135
note . _id ,
You can’t perform that action at this time.
0 commit comments