microsoft / microsoft/fluentui
[Feature]: Dialog - add imperative API for setting virtual parent
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 20.3k
- Forks
- 2.9k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 46
Description
Library
React Components / v9 (@fluentui/react-components)
Describe the feature that you would like added
In this example: https://codesandbox.io/s/determined-aj-h8g7vh?file=/example.tsx
PopoverSurface contains a Button that opens Dialog. Dialog is not children of PopoverSurface in the react tree, and therefore not its virtual child. So when clicking 'close' button to close Dialog, Popover closes as well.
The codesandbox sets Dialog to be the virtual child of PopoverSurface by calling setVirtualParent. So when Dialog closes, Popover can remain open.
What about having a more user friendly API on Dialog that sets the virtual parent? Maybe something like:
React.useEffect(() => {
if (dialogOpen) {
dialogSurfaceRef.current?.setVirtualParent(parentNode);
}
}, [dialogOpen]);
Have you discussed this feature with our team
No response
Additional context
Please note that this is a new feature request. Fluent v0 does not handle this out of the box either: https://codesandbox.io/s/fluent-ui-example-forked-lqde9t?file=/example.js
Validations
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox example and inspect how Dialog currently uses setVirtualParent to preserve the PopoverSurface relationship. Review the React Components / v9 Dialog and Popover behavior, then define and test a user-friendly Dialog API that keeps the Popover open when Dialog closes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100