File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ class TestMenuNodeFactory implements MenuNodeFactory {
5050}
5151
5252describe ( 'menu-model-registry' , ( ) => {
53-
5453 describe ( '01 #register' , ( ) => {
5554 it ( 'Should allow to register menu actions.' , ( ) => {
5655 const fileMenu = [ 'main' , 'File' ] ;
@@ -86,6 +85,9 @@ describe('menu-model-registry', () => {
8685 const openGroup = file . children [ 0 ] as Submenu ;
8786 expect ( openGroup . children . length ) . equals ( 2 ) ;
8887 expect ( openGroup . label ) . undefined ;
88+
89+ expect ( service . getMenuNode ( [ ...fileOpenMenu , 'open' ] ) ) . exist ;
90+ expect ( service . getMenuNode ( [ ...fileOpenMenu , 'Gurkensalat' ] ) ) . undefined ;
8991 } ) ;
9092
9193 it ( 'Should not allow to register cyclic menus.' , ( ) => {
Original file line number Diff line number Diff line change @@ -311,13 +311,15 @@ export class MenuModelRegistry {
311311 }
312312 }
313313
314- protected findInNode ( root : CompoundMenuNode , menuPath : MenuPath , pathIndex : number ) : MenuNode | undefined {
314+ protected findInNode ( root : MenuNode , menuPath : MenuPath , pathIndex : number ) : MenuNode | undefined {
315315 if ( pathIndex === menuPath . length ) {
316316 return root ;
317317 }
318- const child = root . children . find ( c => c . id === menuPath [ pathIndex ] ) ;
319- if ( CompoundMenuNode . is ( child ) ) {
320- return this . findInNode ( child , menuPath , pathIndex + 1 ) ;
318+ if ( CompoundMenuNode . is ( root ) ) {
319+ const child = root . children . find ( c => c . id === menuPath [ pathIndex ] ) ;
320+ if ( child ) {
321+ return this . findInNode ( child , menuPath , pathIndex + 1 ) ;
322+ }
321323 }
322324 return undefined ;
323325 }
You can’t perform that action at this time.
0 commit comments