Skip to content

Conversation

@dgreif
Copy link
Member

@dgreif dgreif commented Jul 20, 2021

As noted in https://github.com/github/primer/issues/240, the updates from #1322 caused the AnchoredOverlay components to start positioning erratically. After further investigation, I found that they were actually being position at the bottom of the page (wherever the Portal is located) and rendered to determine their size before positioning. Because #1322 removed the visibility: hidden style, they were both visible and focusable before actually being positioned. The focus trap would activate, causing the page to scroll to the bottom, and then the position would be calculated from the anchor. This caused the menus in full page apps to be off significantly.

Here I'm bringing back the visibility property on Overlay to allow for temporarily hiding Overlays before positioning. I've tested this in the new Projects Beta and it's working as expected.

I also found a small bug with SelectPanels when they transitioned from a loading: true to loading: false state. Because the FilteredActionList doesn't render the List element until loading is done, the listContainerRef was null when the useFocusZone call was made. We need to ensure useFocusZone re-checks the ref when loading changes, so I added it to the dependencies param.

Closes https://github.com/github/primer/issues/240

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@dgreif dgreif requested review from VanAnderson and smockle July 20, 2021 04:47
@changeset-bot
Copy link

changeset-bot bot commented Jul 20, 2021

⚠️ No Changeset found

Latest commit: 50b0d35

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jul 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/2mA2LQp2sWStLGvdG78yw1ko7y6w
✅ Preview: https://primer-components-git-overlay-hidden-while-positioning-primer.vercel.app

src/Overlay.tsx Outdated
}
}
visibility: ${props => props.visibility || 'visible'};
Copy link
Member

@smockle smockle Jul 20, 2021

Choose a reason for hiding this comment

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

Non-blocking: Would it be better to use a CSS variable for this (ref https://www.joshwcomeau.com/css/styled-components/#css-variables)?

I don’t feel strongly, since these styles already read props in other places (e.g. lines 60–62).

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch! After a month with my head out of PRC, this didn't occur to me but is definitely a pattern I want to keep bringing in wherever possible. Fixed in 54d8783

Copy link
Member

@smockle smockle left a comment

Choose a reason for hiding this comment

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

Nice job tracking this down! Left a non-blocking comment above.

Non-blocking: Can we add a test for this? Either automatic, or a tall tale in Storybook for manual testing?

@vercel vercel bot temporarily deployed to Preview July 20, 2021 14:57 Inactive
@vercel vercel bot temporarily deployed to Preview July 20, 2021 15:11 Inactive
@dgreif
Copy link
Member Author

dgreif commented Jul 20, 2021

Added a test with the anchored overlay open, but I'm not sure I can recreate the scroll issues in JSDOM. Added a story as well for manual testing.

@dgreif dgreif force-pushed the overlay-hidden-while-positioning branch from 090e669 to 88022ac Compare July 20, 2021 18:51
@vercel vercel bot temporarily deployed to Preview July 20, 2021 18:51 Inactive
@dgreif dgreif enabled auto-merge (squash) July 20, 2021 18:52
@dgreif dgreif force-pushed the overlay-hidden-while-positioning branch from 88022ac to b66f1a4 Compare July 26, 2021 16:25
@vercel vercel bot temporarily deployed to Preview July 26, 2021 16:25 Inactive
@dgreif dgreif force-pushed the overlay-hidden-while-positioning branch from b66f1a4 to 50b0d35 Compare July 26, 2021 16:32
@vercel vercel bot temporarily deployed to Preview July 26, 2021 16:32 Inactive
@dgreif dgreif merged commit c0f1ca5 into main Jul 26, 2021
@dgreif dgreif deleted the overlay-hidden-while-positioning branch July 26, 2021 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants