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
AnchoredOverlay + useAnchoredPosition: close overlay when menu goes out of view #2200
Conversation
🦋 Changeset detectedLatest commit: 3505214 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
|
👋 Hi @siddharthkp - Would you cc @primer/accessibility-reviewers when this is out of Draft? 🙏 |
|
cc @primer/accessibility-reviewers for review :) Context: In the tree view in memex, when you interact with a table cell, it opens a select panel and we allow users to scroll the table while select panel is open. While scrolling, when the table cell that opened the select panel goes out of view, i'd like to close the dialog automatically, but I'm not sure what are the accessibility concerns of this approach if you'd like to see a running example in memex, it's live here: https://github-9b5cf0a362-12535706.drafts.github.io/orgs/app/projects/1 |
@siddharthkp I’m not sure this is an “accessibility” issue per se, but I noticed some unexpected behavior related to scroll-bouncing while I was testing this, so I made a screen recording. I’m using Safari on macOS. When I overscroll the list of rows, I briefly see several empty rows, then scroll position snaps/bounces back. Sometimes, this means a cell can briefly go offscreen but then quickly return on-screen. When that cell has an open menu, the menu is closed, even if the cell is again visible after the scrolling+bouncing is complete. Caption: Screen recording of an open menu closing after its associated cell bounces back into view post-scrolling: Menu.closing.when.cell.is.brought.back.into.view.post-bounce.mov |
|
Other menus on github.com remain open as the page is scrolled, even if they are scrolled out of view. Here is the issue comment menu, for example (screen recording below). I’d expect all menus to behave consistently. Caption: Screen recording showing that the issue comment three-dot menu remains open even after it scrolls out-of-view: Issue.comment.three-dot.menu.remains.open.if.it.scrolls.out.of.view.mov |
Yes! that was my concern as well. The suggestion to close it came after my first iteration where it stays open: Description: There is a sticky header above the table so the select panel awkwardly floats on when the table cell is "tucked under" the header. wutt.mov(in the video, ignore the select panel jumping around, that's not the recommendation) One solution would be to "tuck in" the select panel under sticky header as well. From an implementation point of view, that might be tricky or finicky because the select panel needs to render in a portal "above" the table but below the header. |
|
👋🏻 @siddharthkp just doing some triage on the PRC board and this one has been in "ready for review" for a while. Is this still active? |
We still need it 😅 but I haven't touched this in few weeks since floating it for a11y feedback. Will have to schedule this to a different time, going to convert to draft for now |
|
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
Changes
useAnchoredPositionto observe changes to anchor element:observeobservewhich means overlay re-positions based on changes to anchor's position (scroll, resize, etc)SelectPanelnot scrolling with anchoring element #2184video:
overlay-goes-outside.mov
Notes for reviewer:
2.1 Observer is only initiated when overlay is open
2.2 Callback is debounced (16ms) to make sure we're not updating state too fast
Checklist: