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

fix(tooltip): fix tooltip and popover not closing on escape #6108 #6177

Closed

Conversation

iamfozzy
Copy link
Contributor

This PR fixes issue #6108

@iamfozzy iamfozzy force-pushed the fix/tooltip-close-on-escape branch from f4a43fd to 6ddddc3 Compare August 18, 2016 20:08
@@ -71,18 +71,17 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
*/
this.$get = ['$window', '$compile', '$timeout', '$document', '$uibPosition', '$interpolate', '$rootScope', '$parse', '$$stackedMap', function($window, $compile, $timeout, $document, $position, $interpolate, $rootScope, $parse, $$stackedMap) {
var openedTooltips = $$stackedMap.createNew();
$document.on('keypress', keypressListener);
$document.on('keyup', keypressListener);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? Seems like it could still be kept on keypress and work fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just run a quick test in chrome and keypress when pressing esc is not being captured, whereas keyup is.

If you goto http://plnkr.co/edit/WVTd5prw08Mj7tF6vEI4?p=info and place a breakpoint on uibs.js:4720 in chrome then open a popup and press escape. For me - that method is never fired when using keypress.

Comment here #6108 (comment)

The below also comes to mind:
angular/angular.js#10905
http://stackoverflow.com/questions/3901063/jquerys-keypress-doesnt-work-for-some-keys-in-chrome-how-to-work-around

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really weird - is this only with jQuery loaded? I haven't seen this problem when it is just angular with no jQuery.

Copy link
Contributor Author

@iamfozzy iamfozzy Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. Another issue where keypress was the problem and replacing with keydown solves: #5013

Have you tried with the plunker?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, your Plunker does seem to indicate it being an issue. I guess I'm ok with this change then.

@wesleycho
Copy link
Contributor

The crux of this change feels correct to me with the movement of where the new tooltip is added, but I'm not certain that the keypress listener needs to be changed to a keyup listener - if those changes are removed, I'd be inclined to merge it.

Many thanks for this PR! I have investigated this a few different times, and felt that there was something wrong with when the tooltip was added, but could not place my finger on exactly what was happening.

@wesleycho
Copy link
Contributor

This LGTM - thanks a lot!

@wesleycho wesleycho closed this in f5ff12c Aug 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants