react-modal-sheet icon indicating copy to clipboard operation
react-modal-sheet copied to clipboard

Sheet disappears after few closings on iOS

Open andrewLapshov opened this issue 1 year ago • 3 comments

Hello! After toggling the isOpen state several times, Sheet stops displaying. I've tried with both rootId and without, but the result is the same. I've checked on earlier versions of iOS using Browserstack, but I couldn't reproduce the issue.

iOS 17.5.1 react-modal-sheet 3.1.0

export const FiltersSheet = () => {
    const [isOpen, setIsOpen] = useState(false);

    return (
        <>
            <div className={styles.filterContainer}>
                <button className={styles.filterButton} onClick={() => setIsOpen((isOpen) => !isOpen)}>
                    <FilterIcon />
                </button>
            </div>

            <Sheet detent="content-height" isOpen={isOpen} rootId="root" onClose={() => setIsOpen(false)}>
                <Sheet.Container>
                    <Sheet.Header />
                    <Sheet.Content>
                        <Sheet.Scroller>
                            <h2 className={styles.title}>Filters</h2>
                        </Sheet.Scroller>
                    </Sheet.Content>
                </Sheet.Container>
            </Sheet>
        </>
    );
};

https://github.com/Temzasse/react-modal-sheet/assets/55600612/1e04a591-b1a8-4b01-86d0-461f43ea7154

andrewLapshov avatar Jun 11 '24 10:06 andrewLapshov

I faced this issue also on Firefox. I temporarily solved the issue by displaying the modal only when the show state is true:

{show && <ReactSheetModal ... />

The only problem with this approach is that the modal will be unmounted when the modal gets closed, but the user won't notice any difference.

Waiting for a fix...

Pouria-Rezaeii avatar Sep 10 '24 08:09 Pouria-Rezaeii

Hi @andrewLapshov and @Pouria-Rezaeii 👋🏻

I'm not able to reproduce this issue locally. Could you try the latest version of react-modal-sheet and check if the problem still occurs?

If the issue is still happening it would be super helpful to get a reproduction in CodeSandbox or StackBlitz 🙏🏻

Temzasse avatar Oct 27 '24 12:10 Temzasse

I think it's related to the motion, and I was able to fix this with the following zIndex and visibility setting:

<Sheet
  ref={ref}
  disableDrag={disableDrag}
  snapPoints={[0.9, 0.5]}
  initialSnap={1}
  isOpen={isOpen}
  onClose={() => toggle('hide')}
  onSnap={handleSnap}
  style={{
     zIndex: isOpen ? '9999999' : '-1',
     visibility: isOpen ? 'visible' : 'hidden'
  }}>

khashashin avatar Nov 22 '24 15:11 khashashin