re base code

Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@att.com>
diff --git a/catalog-ui/src/app/utils/menu-handler.ts b/catalog-ui/src/app/utils/menu-handler.ts
index fc6eb20..4c25a02 100644
--- a/catalog-ui/src/app/utils/menu-handler.ts
+++ b/catalog-ui/src/app/utils/menu-handler.ts
@@ -65,7 +65,10 @@
     }
 
     public updateSelectedMenuItemText(newText:string) {
-        this.menuItems[this.selectedIndex].text = newText;
+        const selectedMenuItem = this.menuItems[this.selectedIndex];
+        if (selectedMenuItem) {
+            this.menuItems[this.selectedIndex].text = newText;
+        }
     }
 }
 
@@ -112,7 +115,7 @@
         // If not found search by name (name is unique).
         if (selectedItemIdx === -1) {
             selectedItemIdx = _.findIndex(components, (item:Component) => {
-                return item.name === selected.name;
+                return item.name === selected.name && item.componentType === selected.componentType;
             });
         }
 
@@ -144,6 +147,22 @@
                 //  menuItem.text = component.name;
                 result.menuItems.push(menuItem);
             });
+
+            result.selectedIndex = this.findBreadcrumbComponentIndex(components, selected);
+
+            // if component does not exist, then add a temporary menu item for the current component
+            if (result.selectedIndex === -1) {
+                let menuItem = new MenuItem(
+                    //  component.name,
+                    selected.getComponentSubType() + ': ' + this.$filter('resourceName')(selected.name),
+                    clickItemCallback,
+                    null,
+                    null,
+                    [selected]
+                );
+                result.menuItems.unshift(menuItem);
+                result.selectedIndex = 0;
+            }
         }
         return result;
     };