<!doctype html>
<html ng-app="ui.bootstrap.demo">
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.js"></script>
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.2.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>

<div ng-controller="TooltipDemoCtrl">
  
  <p>The issue is, when a button element inside a btn-group has a uib-tooltip and position is set to top (top-left also seems to cause the issue), when mousing over from the top edge of the button, the tooltip is triggered and hidden infitnitely, locking the button and causing a bad visual experience. This only started to occur post migration to the uib prefix. It seems to be caused by a combination of the size of text in the button and the size of the text in the tooltip</p>
  
  <div class="form-group">
    <label>Tooltip placement</label>
    <select class="form-control" ng-model="placement.selected" ng-options="o as o for o in placement.options"></select>
  </div>
  
  <h4 class="alert-success">This Works (tooltip="On the {{placement.selected}}")</h4>  
    <div class="btn-group" uib-dropdown is-open="status.isopen">    
      <button tooltip-placement="{{placement.selected}}" uib-tooltip="On the {{placement.selected}}" type="button" class="btn btn-default dropdown-toggle" uib-dropdown-toggle aria-label="Left Align">
        <span ng-show="minimized" class="glyphicon glyphicon-wrench"></span>
        <span ng-hide="minimized">Tools</span>
        &nbsp;<span class="caret"></span>
      </button>
    </div>
    
    <h4 class="alert-danger">This Fails (tooltip="On the1 {{placement.selected}}") When "top" is selected.</h4>  
    <div class="btn-group" uib-dropdown is-open="status.isopen">    
      <button tooltip-placement="{{placement.selected}}" uib-tooltip="On the1 {{placement.selected}}" type="button" class="btn btn-default dropdown-toggle" uib-dropdown-toggle aria-label="Left Align">
        <span ng-show="minimized" class="glyphicon glyphicon-wrench"></span>
        <span ng-hide="minimized">Tools</span>
        &nbsp;<span class="caret"></span>
      </button>
    </div>

    <h4 class="alert-success">When not in a btn-group it works with the bad tooltip</h4>  
    <button tooltip-placement="{{placement.selected}}" uib-tooltip="On the1 {{placement.selected}}" type="button" class="btn btn-default dropdown-toggle" uib-dropdown-toggle aria-label="Left Align">
      <span ng-show="minimized" class="glyphicon glyphicon-wrench"></span>
      <span ng-hide="minimized">Tools</span>
      &nbsp;<span class="caret"></span>
    </button>
    
    <h4 class="alert-danger">Stripping uib-dropdown out, issue is still here</h4>  
    <div class="btn-group">
      <button tooltip-placement="{{placement.selected}}" uib-tooltip="On the1 {{placement.selected}}" type="button" class="btn btn-default" aria-label="Left Align">
        <span ng-show="minimized" class="glyphicon glyphicon-wrench"></span>
        <span ng-hide="minimized">Tools</span>
        &nbsp;<span class="caret"></span>
      </button>
    </div>
    
    <h4 class="alert-success">Long text in the button and it appears to work</h4>  
    <div class="btn-group">
      <button tooltip-placement="{{placement.selected}}" uib-tooltip="On the1 {{placement.selected}}" type="button" class="btn btn-default" aria-label="Left Align">
        Long text makes it work
      </button>
    </div>
    
    <h4 class="alert-danger">Short text in the button and the issue reappears</h4>  
    <div class="btn-group">
      <button tooltip-placement="{{placement.selected}}" uib-tooltip="On the1 {{placement.selected}}" type="button" class="btn btn-default" aria-label="Left Align">
        Short
      </button>
    </div>
    
</div>
  </body>
</html>
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TooltipDemoCtrl', function ($scope, $sce) {
  $scope.dynamicTooltip = 'Hello, World!';
  $scope.dynamicTooltipText = 'dynamic';
  $scope.htmlTooltip = $sce.trustAsHtml('I\'ve been made <b>bold</b>!');
  $scope.placement = {
    options: [
      'top',
      'top-left',
      'top-right',
      'bottom',
      'bottom-left',
      'bottom-right',
      'left',
      'left-top',
      'left-bottom',
      'right',
      'right-top',
      'right-bottom'
    ],
    selected: 'top'
  };
});