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

bug(demo): Dropdown "Toggle button dropdown" doesn't close in demo #478

Closed
iuristona opened this issue May 3, 2016 · 4 comments
Closed

Comments

@iuristona
Copy link

The "Toggle button dropdown" doesn't close once it is opened.
Another similiar bug occurs when the dropdownToggle contains childrens.
<a dropdownToggle> <i class="icon-bell"></i> <span class="badge badge-default">7</span> </a>

@erashu212
Copy link
Contributor

Hi @iuristona ,

Did you try adding [(isOpen)]="status.isopen"? If yes please add a plnkr link here .

Thanks

@davidloiret
Copy link
Contributor

Any update on this issue?

@felixkubli
Copy link
Contributor

felixkubli commented Sep 27, 2016

The problem is, as soon as the opened dropdown looses it's focus, status.isopen will be changed to false. Then, with toggleDropdown($event) it gets changed back to true again.
Therefore, to close the dropdown, status.isopen doesn't need to bee toggled again.

@felixkubli
Copy link
Contributor

I have come up with an almost complete solution to the problem: I defined a second status variable in dropdown-demo.ts, wich only gets toggled you click the "Toggle button dropdown" - button:

export class DropdownDemoComponent {
  public disabled:boolean = false;
  public status:{isopen:boolean, isOpenedByButton:boolean} = {isopen: false, isOpenedByButton: false};
  public items:Array<string> = ['The first choice!',
    'And another choice for you.', 'but wait! A third!'];

  public toggled(open:boolean):void {
    console.log('Dropdown is now: ', open);
  }

  public toggleDropdown($event:MouseEvent):void {
    $event.preventDefault();
    $event.stopPropagation();
    this.status.isOpenedByButton = !this.status.isOpenedByButton;
    this.status.isopen = this.status.isOpenedByButton;
  }
}

The only problem is, that when you close the dropdown by clicking anywhere else in the window, you need to press the button twice to reopen the dropdown, because it first attempts to close it.

valorkin added a commit that referenced this issue Mar 24, 2017
fixes #1674, fixes #1749, fixes #1623, fixes #1415, fixes #802, fixes #569, fixes #530, fixes #6,
fixes #1540, fixes #1217, fixes #591, fixes #478
valorkin added a commit that referenced this issue Mar 24, 2017
fixes #1674, fixes #1749, fixes #1623, fixes #1415, fixes #802, fixes #569, fixes #530, fixes #6,
fixes #1540, fixes #1217, fixes #591, fixes #478
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

5 participants