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

[AIRFLOW-4357] Fix SVG tooltip positioning with custom scripting #8269

Merged
merged 3 commits into from
Apr 23, 2020
Merged

[AIRFLOW-4357] Fix SVG tooltip positioning with custom scripting #8269

merged 3 commits into from
Apr 23, 2020

Conversation

ryanahamilton
Copy link
Contributor

@ryanahamilton ryanahamilton commented Apr 13, 2020

Resolves AIRFLOW-4357.

Tooltip positioning was not being calculated correctly after scrolling due to a known issue in jQuery (that won't be fixed).

My solution implements a custom tooltip script for proper positioning on SVG elements. I've replicated the markup and CSS classes of the existing Tooltips, so these visually look identical to the others and require no new CSS.

I've tested/confirmed the fix in modern Chrome, Safari, Firefox, and Edge browsers.

Screen Recording 2020-04-13 at 12 48 PM


Make sure to mark the boxes below before creating PR: [x]


In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Apr 13, 2020
@kaxil kaxil added this to the Airflow 1.10.11 milestone Apr 13, 2020
@kaxil kaxil requested review from kaxil and ashb April 13, 2020 16:56
$('body').on('mouseover', '.has-svg-tooltip', function(e) {
var elem = e.target;
var text = elem.getAttribute('title');
var circ = document.getElementById(elem.id).getBoundingClientRect();
Copy link
Member

Choose a reason for hiding this comment

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

Isn't document.getElementById(elem.id) just elem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

var centeringOffset = tip.width() / 2;
tip.css({
"display": "block",
"left": offsetLeft + 12.5 - centeringOffset + 'px',// 12.5 == half of circle width
Copy link
Member

Choose a reason for hiding this comment

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

Rather than hard-coding these offsets, would it be cleaner/less future error prone to instead pass in the result of getBoundingClientRect, i.e. this function beceomes:

     function showSvgTooltip(text, elemClientRect) { 

or

     function showSvgTooltip(text, elemTop, elemLeft, elemBottom, elemRight ) { 

(TLBR, instead of TLXY as IEs' don't have X and Y attributes according to https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)

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 simplified the function argument similar to your first suggestion.

Your IE comment caused some confusion for me—I was thinking that I had used the unsupported getboundingclientrect properties, though that wasn't the fact. I did end up confirming that this works in IE Edge. I also tested in an IE11 instance, but the UI failed to operate properly. Those are either much larger compatibility issues or due to unresponsiveness of the VirtualBox instance I was testing in.

Copy link
Member

Choose a reason for hiding this comment

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

Whops sorry!

@kaxil
Copy link
Member

kaxil commented Apr 22, 2020

🎉 @ryanahamilton

@kaxil kaxil merged commit eb7255f into apache:master Apr 23, 2020
@ryanahamilton ryanahamilton deleted the fix_svg_tooltips branch April 23, 2020 18:40
kaxil pushed a commit that referenced this pull request Jun 22, 2020
potiuk pushed a commit that referenced this pull request Jun 29, 2020
kaxil pushed a commit that referenced this pull request Jul 1, 2020
@ryanahamilton ryanahamilton added the area:UI Related to UI/UX. For Frontend Developers. label Nov 18, 2020
cfei18 pushed a commit to cfei18/incubator-airflow that referenced this pull request Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants