vaadin / vaadin-context-menu

The responsive Web Component for showing context dependent items for any element on the page. Part of the Vaadin components.
https://vaadin.com/components
Apache License 2.0
26 stars 10 forks source link

TypeError: Cannot read property '0' of undefined #227

Closed Skrikjo closed 5 years ago

Skrikjo commented 5 years ago

When context menu have no items error is showed: TypeError: Cannot read property '0' of undefined More details from exception:

vaadin-list-mixin.html:193 Uncaught TypeError: Cannot read property '0' of undefined
    at HTMLElement.focus (vaadin-list-mixin.html:193)
    at HTMLElement._onVaadinOverlayOpen (vaadin-context-menu.html:394)
    at HTMLElement.handler (template-stamp.html:96)
    at HTMLElement.Polymer.RenderStatus.afterNextRender (vaadin-overlay.html:546)
    at callMethod (render-status.html:51)
    at runQueue (render-status.html:42)
    at render-status.html:29

Looks like in before calling child.focus() at vaadin-context-menu.html:394 check that child.items[0] is defined missing.

How to reproduse

  1. Create context menu with no item.
  2. bind it to target
  3. right click on target
        Span contextTarget = new Span("Context menu target");
        ContextMenu menu = new ContextMenu(contextTarget);
        add(contextTarget);