-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
select components: props appendTo
Incorrect first time mount
#5311
Comments
appendTo
Incorrect first time mountappendTo
Incorrect first time mount
Fix #5311: AppendTo should be correct on mount
@kl-nevermore please try 10.1.0 and confirm your issue is fixed. |
sorry! I just saw this message! |
https://codesandbox.io/p/sandbox/primereact-demo-forked-wn2yc7 |
Can you investigate? What I fixed was in useMountEffect(() => {
alignOverlay();
});
const alignOverlay = () => {
DomHandler.alignOverlay(overlayRef.current, labelRef.current.parentElement, props.appendTo || (context && context.appendTo) || PrimeReact.appendTo);
}; So on Mount of the component the overlay should already be set to append to the correct spot where before it was waiting until it was shown the first time to appendTo? |
Whether use ref or selectors ,the I have two solutions const ref = useRef();
const [refState, setRefState] = useState();
useEffect(() => {
setRefState(ref.current);
}, []);
<div ref={ref}>append to</div>
<MultiSelect appendTo={refState} />; 2: <MultiSelect appendTo={()=>ref.current} />; |
I like solution 2 above. |
Describe the bug
when use
appendTo
,the first time it was appended to the body, the second time it was mounted correctlymaybe all select components have this issue but
Dialog
okCascadeSelect
MultiSelect
Reproducer
https://codesandbox.io/s/primereact-demo-forked-tk9y7q?file=/src/D.js:53-59
PrimeReact version
10.0.9 and the master branch code
React version
17.x
Language
TypeScript
Build / Runtime
Create React App (CRA)
Browser(s)
Chrome 118
Steps to reproduce the behavior
No response
Expected behavior
If appendTo is an HTML element, should it be used for calculation?( like MultiSelect ? )
or
mounted correctly, the position does not change(like antd)
No response
The text was updated successfully, but these errors were encountered: