-
Notifications
You must be signed in to change notification settings - Fork 12
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
getAnchoredPosition
does not respect margin
on document body
#242
Comments
Thanks for reporting! I'll poke around the function to see if there are any unintentional effects of including margin 😇 |
@EnixCoda would you like to make a PR? With a PR we could try integrating it to see if there are any adverse effects (I think unlikely as we have margin:0 on body?). |
Hi all! 👋 Just wanted to leave a comment to check-in and see if this issue was still present and, if not, to close out this issue. |
Hi @joshblack Yes this issue still presents. |
Hi! This issue has been marked as stale because it has been open with no activity for 180 days. You can comment on the issue or remove the stale label to keep it open. If you do nothing, this issue will be closed in 7 days. |
ping |
Hi @lesliecdubs I'd like to give a try. But the required change is beyond what I can do using Chrome devtool Override Content feature. I need help setting up the dev env. I'm not familiar enough with the primer components to reproduce the issue locally. I can not find the same component. It would be wonderful if you could help make a codesandbox.io demo that could reproduce the issue. Then I could try fix it. |
@EnixCoda I wouldn't worry about having it working exactly the same as the bug. Try to set up a reduced code example in something like a codesandbox, that exemplifies the same issue and work to that. |
I guess AnchoredOverlay was the correct component. Then I tried to create a codesandbox but it failed to run. https://codesandbox.io/p/sandbox/wls675 However, I made it to work locally. So I believe that was a bug of codesandbox, not primer. But the issue cannot be reproduced locally. Some differences I have noticed
Note: I deleted some elements from GitHub page. And the component still works without re-rendering the rest part of page. This also proves that it is not a react component. If GitHub page is rendered with Rails instead of react. Would you briefly describe what should I do to reproduce it? Thanks! |
Hi, I noticed that the tooltips in PR pages are not aligned properly when
body
hasmargin
set.Check out the comparison below, you can see the tooltip shifts
200px
relative to body between the 2 cases. And200px
is exactly themargin-left
set tobody
.200px
margin on bodyWhy would body has
margin
?I noticed this issue because I use a GitHub browser extension that adds a sidebar to the page and set margin to body so that the sidebar would not overlap page content. I understand that
primer
is not responsible for handling of user's browser extension use case. But perhaps my use case has revealed a tiny defect of primer/behaviors and would help improve it. :)Some insights I have noticed
Tooltip's position was set by
https://github.com/primer/view_components/blob/81eea01d0034c55771ce3e6c2afc685d364afc6c/app/components/primer/alpha/tool_tip.ts#L416-L417
And the position was calculated from
getAnchoredPosition
behaviors/src/anchored-position.ts
Line 140 in 6ed742f
In
getAnchoredPosition
, therelativeRect
has the correctleft
value for tooltip, if it was set to tooltip'sleft
style, it would align properly.behaviors/src/anchored-position.ts
Lines 153 to 156 in 6ed742f
However, the
relativeRect
was then passed topureCalculateAnchoredPosition
and it returned a differentleft
.behaviors/src/anchored-position.ts
Lines 290 to 379 in 6ed742f
Thank you for this awesome project!
The text was updated successfully, but these errors were encountered: