@@ -104,7 +104,6 @@ export class SearchBar {
104104 if ( this . activeQuery . size === 0 ) {
105105 this . allSearchPackages . forEach ( ( element ) => element . classList . add ( "hide" ) ) ;
106106 }
107-
108107 // if backspace is received and that we have active queries
109108 // then we want the query to be re-inserted in the input field!
110109 else if ( event . key === "Backspace" ) {
@@ -116,6 +115,17 @@ export class SearchBar {
116115 confirmBackspace = true ;
117116 }
118117 }
118+ else if ( event . key === "Enter" ) {
119+ const nodeIds = [ ] ;
120+
121+ for ( const pkgElement of this . allSearchPackages ) {
122+ if ( ! pkgElement . classList . contains ( "hide" ) ) {
123+ nodeIds . push ( Number ( pkgElement . getAttribute ( "data-value" ) ) ) ;
124+ }
125+ }
126+
127+ this . focusMultipleNodeIds ( nodeIds ) ;
128+ }
119129
120130 return ;
121131 }
@@ -164,6 +174,7 @@ export class SearchBar {
164174 this . input . value . slice ( currentActiveQueryName . length + 1 ) . trim ( ) ;
165175
166176 this . showHelperByInputText ( text ) ;
177+
167178 if ( text . length === 0 ) {
168179 return ;
169180 }
@@ -186,6 +197,7 @@ export class SearchBar {
186197 return ;
187198 }
188199 }
200+
189201 this . showResultsByIds ( matchingIds ) ;
190202 } ) ;
191203
@@ -201,7 +213,7 @@ export class SearchBar {
201213 const self = this ;
202214 for ( const domElement of this . allSearchPackages ) {
203215 domElement . addEventListener ( "click" , function clikEvent ( ) {
204- self . resultRowClick ( this . getAttribute ( "data-value" ) ) ;
216+ self . focusNodeById ( this . getAttribute ( "data-value" ) ) ;
205217 } ) ;
206218 }
207219 }
@@ -381,10 +393,27 @@ export class SearchBar {
381393 return storedIds . size === 0 ? matchingIds : new Set ( [ ...matchingIds ] . filter ( ( value ) => storedIds . has ( value ) ) ) ;
382394 }
383395
384- resultRowClick ( dataValue ) {
396+ focusNodeById ( nodeId ) {
385397 window . navigation . setNavByName ( "network--view" ) ;
386398 this . delayOpenSearchBar = false ;
387- this . network . focusNodeById ( dataValue ) ;
399+ this . network . focusNodeById ( nodeId ) ;
400+ this . close ( ) ;
401+
402+ setTimeout ( ( ) => {
403+ this . delayOpenSearchBar = true ;
404+ } , 5 ) ;
405+ }
406+
407+ focusMultipleNodeIds ( nodeIds ) {
408+ window . navigation . setNavByName ( "network--view" ) ;
409+ this . delayOpenSearchBar = false ;
410+
411+ if ( window . locker . locked ) {
412+ this . network . resetHighlight ( ) ;
413+ }
414+ this . network . highlightMultipleNodes ( nodeIds ) ;
415+ window . locker . lock ( ) ;
416+
388417 this . close ( ) ;
389418
390419 setTimeout ( ( ) => {
0 commit comments