Closed as not planned
Closed as not planned
Description
Describe the bug
The current way the Portal is written, mounts its children on a detached node. This causes children that need to use autoFocus
or measure themselves to fail.
To Reproduce
Steps to reproduce the behavior:
- Example below will not be able to auto focus the input.
export const TestDialog = () => {
return (
<Dialog2>
<input autoFocus />
</Dialog2>
);
};
- Example below will be able to auto focus the input.
export const TestDialog = () => {
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
return (
<Dialog2>
{mounted && <input autoFocus />}
</Dialog2>
);
};
Expected behavior
Possible change to the way children are rendered, taking into account the different drawbacks detailed here reactjs/react.dev#272 (comment) and an update to the documentation outlining which method has been chosen. Potentially introducing a prop if possible to switch between mounting styles.
Desktop (please complete the following information):
- OS: All
- Browser: All
- Version: v34.2.0
Smartphone (please complete the following information):
- Device: All
- OS: All
- Browser: All
- Version: v34.2.0
Kind Regards
Erik Hughes