adopted-ember-addons / ember-pikaday

A datepicker component for Ember CLI projects.
MIT License
159 stars 169 forks source link

Pikaday close event confuses ember basic dropdown #191

Open andrew-paterson opened 6 years ago

andrew-paterson commented 6 years ago

I'm not sure if this belongs here, as this is more a conflict with another addon than a pikaday specific problem. If a pikaday component is inside the content of an ember-basic-dropdown component, the dropdown closes as soon as a date is clicked. It seems that the close event for the pikaday calendar is bubbling up tothe dropdown.

    {{#basic-dropdown renderInPlace=true as | dd | }}
        {{#dd.trigger class=triggerClasses eventType="click" }}
            <button class="secondary">Show date picker</button>
        {{/dd.trigger}}
        {{#dd.content }}
            {{pikaday-input format="MM/DD/YYYY" onSelection=(action 'doSomethingOnSelection') onClose=(action 'doSomethingOnClose') bubbles=false}}
        {{/dd.content}}
    {{/basic-dropdown}}

I have tried it with a more simple popout and it works correctly:

    <button {{action 'toggleFoo'}}></button>
    {{#if foo}}
        {{pikaday-input format="MM/DD/YYYY" onSelection=(action 'test') onClose=(action 'doSomethingOnClose') bubbling=false}}
    {{/if}}

Is there a way to stop the close event of pikaday from bubbling up in such a case?

scottkidder commented 5 years ago

@andrew-paterson Can you put together a twiddle?

asjongers commented 5 years ago

Hmmm, I've never used ember-basic-dropdown but it could be that it detects any click outside its DOM element and, as the date selector in pikaday-input is not rendered in place (from what I've seen at least), the close action of ember-basic-dropdown gets triggered.

I think the pikaday-inputless is rendered in place so it could be a good starting point to check if it is indeed the issue?