Repository navigation
fix: restore default-open popovers to their trigger - #10696
minwookshin wants to merge 3 commits into
Conversation
snowystinger
left a comment
There was a problem hiding this comment.
We'll want to try and do this without adding any new props if possible
|
Removed the public fallback props. |
| } | ||
|
|
||
| /** @private */ | ||
| export function setFocusScopeRestoreTarget(element: Element, target: FocusableElement): void { |
There was a problem hiding this comment.
I don't think a private export is quite the right solution yet, considering FocusScope is meant to eventually be upstreamed into React. We should try to find a different way to approach this problem.
I know there is precedent with isElementInChildOfActiveScope but I'm pretty sure that was a temporary measure.
|
Thanks for exploring another avenue. Talked with @devongovett and we're more in favour of the first approach you took. A FocusScope prop could be useful in this case. PopoverTrigger and DialogTrigger could set it automatically. |
|
@snowystinger Actually, I think there is a way to avoid both prop and the private method if we take a similar approach to |
|
Thanks for the idea @nwidynski , happy to have that tried out as well, it sounds promising |
|
Switched to the restore-focus event and removed the private export. The trigger only handles restoration from its own overlay when the saved target is body. |
Closes #10661
An overlay opened at mount records
document.bodyas its restore target, leaving focus there after Escape. Pass the closing scope with the existing restore-focus event so the matching trigger can handle that fallback. Existing focus targets retain priority, and the private FocusScope helper is removed.AI-assisted implementation and verification with Codex, following AGENTS.md and the contribution guidance.
✅ Pull Request Checklist:
📝 Test Instructions:
Run
yarn vitest run --config=vitest.browser.config.ts packages/react-aria-components/test/Popover.browser.test.tsx. Escape should return a default-open overlay to its trigger, including after reopening. A previously focused element should remain the restore target. All three default-open cases fail on the unchanged base.All seven cases pass in Chromium, Firefox and WebKit. The final related unit tests, SSR, lint, formatting and type checks pass. Broader local runs hit an existing WebKit Modal failure reproduced on the base, an intermittent DateRangePicker render failure and one Jest worker crash; the affected tests passed separately. The first SSR run timed out at startup, and the second full run passed without changes.
Keyboard and mouse interactions are covered. Screen-reader interaction was not manually tested.
🧢 Your Project:
Independent open-source contribution.