-
Notifications
You must be signed in to change notification settings - Fork 82
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
It can't be closed when even isOpen = true #120
Comments
you need to use a State where you track the open status. if you set the |
Currently the only way to force the sheet to remain open is to re-open it when the user closes it: const [isOpen, setOpen] = useState(false);
return (
<Sheet isOpen={isOpen} onClose={() => setOpen(true)} />
); I'll try to find a better way to force the sheet to remain open 🕵🏻 |
I am also interested in an option to persist the bottom sheet. Id like an option for dragging to stop once it hits the last snap point |
Yeah setting it to useEffect(() => {
if (isOpen) return;
setTimeout(open, 200);
}, [isOpen, open]);
<Sheet isOpen={isOpen} onClose={close} /> Id like the ability for the sheet not to be able to be dragged past the lowest snapPoint and the ability to disable the closing when the drag force is high i.e. Dragging down fast at the highest snapPoint shouldn't cause it to close. |
I have found a way around. So basically, when the isOpen state changes to false, I have added a useEffect hook with isOpen in my dependency array. Once the isOpen changes from true to false, inside the useEffect I will check if the state is false and if it is false I will set it to true. (In my answer, isResultOpen is isOpen) `const [isResultOpen, setIsResultOpen] = useState(false); useEffect(()=>{ ` You might be wondering if it is false by default then it is true by default because on the initial render it is false and then this will be detected and it will be turned into true right away so no time to actually open it. Well, I found a work around that would conditionally render the component as per my use case. |
This was my solution which seems to be working for me. <Sheet isOpen={sheetOpen} onClose={() => setSheetOpen(false)} onCloseEnd={() => setSheetOpen(true)} /> |
<Sheet isOpen={open} onClose={() => {}}>
<Sheet.Container>
<Sheet.Header />
<Sheet.Content>{body}</Sheet.Content>
</Sheet.Container>
<Sheet.Backdrop />
The text was updated successfully, but these errors were encountered: