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

Components: Track scroll position of all parent scrollable nodes #3007

Merged
merged 1 commit into from
Oct 12, 2017

Conversation

youknowriad
Copy link
Contributor

Try to fix #2999

Not sure if there are performance concerns about this, or if it's a good solution but this tries to fix popovers position if we scroll one of their parents.

Testing instructions

  • Hover a button with a tooltip,
  • Scroll slightly
  • The tooltip should adapt its position

@youknowriad youknowriad added the [Type] Bug An existing feature does not function as intended label Oct 12, 2017
@youknowriad youknowriad self-assigned this Oct 12, 2017
@youknowriad youknowriad requested review from aduth and ellatrix October 12, 2017 13:49
@codecov
Copy link

codecov bot commented Oct 12, 2017

Codecov Report

Merging #3007 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3007      +/-   ##
==========================================
- Coverage   34.38%   34.37%   -0.02%     
==========================================
  Files         196      196              
  Lines        5810     5809       -1     
  Branches     1027     1027              
==========================================
- Hits         1998     1997       -1     
  Misses       3222     3222              
  Partials      590      590
Impacted Files Coverage Δ
components/popover/index.js 87.91% <100%> (-0.14%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e09410e...1ded9dc. Read the comment docs.

return [];
}
const parentScrollables = getScrollParents( node.parentNode );
if ( node.scrollHeight > node.clientHeight ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking this doesn't solve the issue if the parent has no scrollbars yet unless we add content later.

@youknowriad youknowriad force-pushed the fix/popover-on-scroll branch from efba698 to 47e1fd0 Compare October 12, 2017 14:25
@youknowriad
Copy link
Contributor Author

Ok simplified this, it looks like using the "capturing" flag catches all scroll events over the page. and it fixes the issue.

@ellatrix
Copy link
Member

return;
}
const { parentNode } = anchor;
Copy link
Member

Choose a reason for hiding this comment

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

Both anchor.parentNode and { parentNode } = anchor in one place feels a bit weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep we could avoid destructuring

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

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

🎉 Works great now.

@youknowriad youknowriad force-pushed the fix/popover-on-scroll branch from 47e1fd0 to 1ded9dc Compare October 12, 2017 14:38
@youknowriad youknowriad merged commit 63cb942 into master Oct 12, 2017
@youknowriad youknowriad deleted the fix/popover-on-scroll branch October 12, 2017 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tooltips do not preserve position on scroll
2 participants