Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dropdown): with autoClose 'outsideClick' closing when clicking inside element #124

Closed
jurgenvo opened this issue Feb 2, 2016 · 2 comments

Comments

@jurgenvo
Copy link

jurgenvo commented Feb 2, 2016

Hi,

i'm working on an implementation of the Dropdown and I'm having some trouble with the autoClose property. I set the autoClose to 'outsideClick' but the dropdown is toggled when I click inside the element as well. Here is what I have:

index.html:

<div id="dropdown-x" class="btn-group" dropdown [autoClose]="'outsideClick'">
    <button type="button" class="btn btn-default" dropdownToggle>
        <span class="glyphicons glyphicons-tag"></span> {{data?.reference}}
        <span class="caret"></span>
    </button>
    <div class="dropdown-menu" dropdownMenu>
        <edit-details [details]="dataDetails" (detailsApplied)="updateDetails($event)">Details</edit-details>
    </div>
</div>

The template of the edit-details component has the following html:

<div id="dropdown-content" *ngIf="details">
    <form role="form">
        <div class="row">
            <div class="col-lg-6">
                <input-text [(value)]="details.name" (input)="valueChanged('name', $event)"></input-text>
                ... some more inputs
            </div>
        </div>
    </form>
</div>

After some debugging I found that in the closeDropdown function in dropdown.service.ts, the this.openScope.menuEl is undefined. I think that the public set dropDownMenu in dropdown.directive.ts is never called, thus the this.menuEl is never set.

Any ideas on this are very welcome. Thanks!

@valorkin valorkin self-assigned this Feb 2, 2016
@valorkin valorkin changed the title Dropdown with autoClose 'outsideClick' closing when clicking inside element chore(dropdown): with autoClose 'outsideClick' closing when clicking inside element Feb 3, 2016
@rluba
Copy link
Contributor

rluba commented Feb 10, 2016

It seems the reason is that the menu is never set for the dropdown. This causes the test whether the clicked element is inside the menu to always be false.

@rluba
Copy link
Contributor

rluba commented Feb 10, 2016

Additionally, the inclusion test only tests for equality instead of doing a proper "contains" check like the original bootstrap code.

rluba added a commit to rluba/ng2-bootstrap that referenced this issue Feb 10, 2016
…ny click

- Implement a `DropdownMenu` directive to fix "always undefined directive.menuEl"
- Test for "OUTSIDECLICK" should not consider menu children to be outside the menu
rluba added a commit to rluba/ng2-bootstrap that referenced this issue Feb 10, 2016
- Implement a `DropdownMenu` directive to fix "always undefined directive.menuEl"
- Test for "OUTSIDECLICK" should not consider menu children to be outside the menu

This fixes valor-software#124
valorkin added a commit that referenced this issue Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants