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

Tooltip positioning & placement improvements #3980

Closed
wants to merge 2 commits into from
Closed

Tooltip positioning & placement improvements #3980

wants to merge 2 commits into from

Conversation

cvn
Copy link
Contributor

@cvn cvn commented Jul 20, 2015

This PR contains two changes:

  1. Only update tooltip position when content changes, instead of every $digest. This fixes a bug where the tooltip would shift a pixel Tooltip shifts 1px #3964, and should be a little more performant.
  2. Adds the ability for changes to tooltip-placement/popover-placement to be reflected by the tooltip immediately Tooltip placement does not update dynamically #3978. The test for this is arguably incomplete, it only checks that the tooltip scope is updated, and doesn't check that the tooltip appearance has changed. I don't really know how to test the latter.

@chrisirhc It looks like you've done the most work on the tooltips recently, I would love to get your opinion on these changes.

@wesleycho
Copy link
Contributor

This PR looks pretty solid to me, although another set of eyes couldn't hurt.

@wesleycho wesleycho added this to the Backlog milestone Jul 21, 2015
@RobJacobs
Copy link
Contributor

I'm not sure if wrapping the call to positionTooltip in $timeout is necessary, have you tried without the $timeouts?

@cvn
Copy link
Contributor Author

cvn commented Jul 21, 2015

Yeah, the $timeouts were necessary in my testing. It might be possible to set priorities on the directives to remove the need for the $timeouts (so that the position calculation always happened after the text was rendered), but I'm just speculating, I didn't attempt this.

if (ttScope.isOpen) {
$timeout(function () {
prepPlacement();
show()();
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this mean that if the placement is changed while the tooltip is hidden, it'll show?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it only runs if ttScope.isOpen is true, so only when it's already open.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, I missed that check, but there's also when the value is a blank string, see above at line #288: if (!val && ttScope.isOpen ) {

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 think this is a slightly different case that warrants a different conditional. On 288, there's new content to deal with and if the content is blank, it should hide the tooltip. Here there's no new content, just a new placement.

cvn added 2 commits July 28, 2015 14:43
- Only update tooltip position when content changes, instead of every $digest

Fixes #3964
@cvn
Copy link
Contributor Author

cvn commented Jul 28, 2015

Thanks @chrisirhc and @RobJacobs for the feedback. I pushed new commits incorporating the suggestions.

@wesleycho
Copy link
Contributor

The changes look good - if @chrisirhc signs off, this should be good to go.

@wesleycho wesleycho modified the milestones: 0.13.x, Backlog Aug 2, 2015
@wesleycho
Copy link
Contributor

I built and tested this PR against the existing reproduction cases - this is some good work. I am going to merge it in right now.

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.

4 participants