@jameshahn2 wrote:
Morning y’all!
Does anyone know how to refactor the components in EmberMap’s Building A Nested Dropdown code (specifically,
dropdown-list-item
anddropdown-list
) in light of RFC 486, which deprecated support for mouseEnter/Leave/Move Ember events?My nested dropdown (dropdown-list-item, dropdown-list, and ui-nav) stopped working after the RFC while throwing
Cannot read property 'nextSibling' of null
andCannot read property 'parentNode' of null
.Tried completely replacing my dropdown in
ui-nav
with @samselikoff’sDropdownList
innav-menu
, which is:<div class="m-4"> <DropdownList class='list-reset flex' as |List|> <List.item class='w-64 p-4 bg-grey-light cursor-pointer' as |Item|> Menu A {{if Item.isActive '(active)'}} </List.item> <List.item data-tether-id="menu-b" class='w-64 p-4 bg-grey-light cursor-pointer' as |Item|> Menu B {{if Item.isActive '(active)'}} {{#if Item.isActive}} {{#modal-dialog tetherTarget='[data-tether-id="menu-b"]' targetAttachment='bottom left' attachment='top left' animatable=true hasOverlay=false }} <Item.sublist class='-mt-2 list-reset bg-white shadow' as |List|> <List.item class='p-4' as |Item|> Submenu 1 {{if Item.isActive '(active)'}} </List.item> <List.item class='p-4 relative' as |Item|> Submenu 2 {{if Item.isActive '(active)'}} {{#if Item.isActive}} <Item.sublist class='absolute bg-white shadow' as |List|> <List.item class='p-2' as |Item|> Sub-submenu 1 {{if Item.isActive '(active)'}} </List.item> <List.item class='p-2'> Sub-submenu 2 </List.item> </Item.sublist> {{/if}} </List.item> </Item.sublist> {{/modal-dialog}} {{/if}} </List.item> </DropdownList> </div>
This throws:
Cannot read property 'addEventListener' of null
and seems to point to a problem here, which is:let { firstNode, lastNode } = Ember.ViewUtils.getViewBounds(this); let firstElement = firstNode instanceof Text ? firstNode.nextElementSibling : firstNode; let lastElement = lastNode instanceof Text ? lastNode.previousElementSibling : lastNode; if (firstElement !== lastElement) { throw `DropdownListItem: An Item's content must have a single root HTML element.`; } this.rootElement = firstElement; this.handleMouseEnter = this.handleMouseEnter.bind(this); this.handleMouseLeave = this.handleMouseLeave.bind(this); this.rootElement.addEventListener('mouseenter', this.handleMouseEnter); this.rootElement.addEventListener('mouseleave', this.handleMouseLeave); },
After adding
There were more nulls than that, but you get the idea.console.log(Ember.ViewUtils.getViewBounds(this))
, the log came back:Haven’t solved any node issues yet, so not sure what to do with this information.
Any ideas?
Posts: 1
Participants: 1