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