RSSchermer / ember-rl-dropdown

Dropdown components and mixin for Ember.
MIT License
15 stars 12 forks source link

When trying to use dropdownExpanded property while accessing from a different DOM, the property is toggled and the dropdown isn't shown #3

Closed abhilashlr closed 9 years ago

abhilashlr commented 9 years ago

What the problem is? Have a DOM (with class rl-dropdown-toggle) that sets the "dropdownExpanded" property to true on click. This property will be used in the dropdown DOM (rl-dropdown). I set this property through a service and have it synced two way via Ember.computed.alias(). As a result this property is set, and reset again, due to the "clickoutHandler" method. The IF condition seems to not work and I have to explicitly overwrite this method.

if(component.get('dropdownExpanded') && $target.closest('html').length !== 0 && !($target.closest($c.find(component.get('dropdownToggleSelector'))).length || $target.closest($c.find(component.get('dropdownSelector'))).length) )

Instead of saying $target.closest having a length > 0, we could use $target.is(component.get('dropdownSelector')) and $target.is(component.get('dropdownToggleSelector') thereby causing the clickoutHandler method to function properly.

RSSchermer commented 9 years ago

Thanks for tracking down this issue! Let me attempt to summarize the problem:

You're using the mixin in a custom component, correct? You're trying to set the dropdownExpanded property programmatically by aliasing it to another property, but the dropdown wont stay open and closes immediately, because the clickoutHandler fires.

It should definitely be possible to open the dropdown programmatically and I'll look into it. Unfortunately, I happen be in an exceptionally busy weekend at the moment, so it may take me a couple of days to get around to it.

abhilashlr commented 9 years ago

@RSSchermer, that's exactly what I do!

RSSchermer commented 9 years ago

Just published version 0.2.3, let me know if that fixes your problem.

abhilashlr commented 9 years ago

Yeah! Works now. Thanks @RSSchermer