Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

is-open of dropdowns is not working with dynamic (ng-repeat) tabs #3261

Closed
initiatus opened this issue Feb 6, 2015 · 8 comments
Closed

is-open of dropdowns is not working with dynamic (ng-repeat) tabs #3261

initiatus opened this issue Feb 6, 2015 · 8 comments

Comments

@initiatus
Copy link

http://plnkr.co/edit/fhQrZWOyEjkjKcbiP78k

The is-open directive is not working if being placed into tabs generated by ng-repeat. It is working good within static tabs and outside tabs though.

@Delapouite
Copy link

The problem lies in this condition :

    if ( openScope && openScope !== dropdownScope ) {
        openScope.isOpen = false;
    }

https://github.com/angular-ui/bootstrap/blob/master/src/dropdown/dropdown.js#L16-L18

which always close the dropdown menu as soon it's opened.

@austinpray
Copy link

Would love to PR but don't know what problem

if ( openScope && openScope !== dropdownScope ) {
openScope.isOpen = false;
}
is solving.

@wesleycho
Copy link
Contributor

That is not the source of the problem - did some investigation, and it turns out the dropdown directive instantiates twice.

@wesleycho wesleycho added this to the 0.13.3 (Performance) milestone Aug 1, 2015
@wesleycho
Copy link
Contributor

Elaborating further, this appears to be because of the tab component - the tabset directive uses the tab-content-transclude directive, which copies the HTML of the content of the tab and moves it into a different element.

Here is a fork of the Plunker based off of master that demonstrates the problem.

@wesleycho
Copy link
Contributor

I apologize, looks like my observation is incorrect - something really funky is going on. With each click, both dropdown buttons are toggling.

@wesleycho wesleycho modified the milestones: 0.13.3 (Fixes), 0.13.4 (Performance) Aug 9, 2015
@wesleycho wesleycho modified the milestones: 1.1.1, 1.1.0, 1.1.2 Jan 18, 2016
@wesleycho wesleycho modified the milestones: 1.1.2, 1.2.0 Feb 1, 2016
@wesleycho wesleycho modified the milestones: 1.2.0, 1.2.1, 1.2.2, 1.3.0 Feb 26, 2016
@wesleycho
Copy link
Contributor

@sagorshkov great catch - will open PR with fix shortly.

@allnash
Copy link

allnash commented Apr 4, 2018

I think the way I fixed it was this way for ng-repeat. when there is an <a> element, the ngTouch messes up with the elements and how they fire events.

HTML

<a ng-click="toggleDropdown($event)" id="project-participant-dropdown-[[participant.id]]" ng-repeat="participant in project.current_cycle.participants" uib-dropdown-toggle>
   <img alt="image" class="img-circle" ng-src="[[participant.image.url]]">
</a>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="project-participant-dropdown-[[participant.id]]">
   <li role="menuitem">
     <a ng-click="removeParticipant(participant)">Remove</a>
   </li>
   <li>
      <a ng-click="messageParticipant(participant)">Message</a>
   </li>
</ul>

JS
  $scope.status = {
    isopen: false
  };


$scope.toggleDropdown = function($event) {
    $event.preventDefault();
    $event.stopPropagation();
    $scope.status.isopen = !$scope.status.isopen;
  };

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants