Temzasse / react-modal-sheet

Flexible bottom sheet component built with Framer Motion to provide buttery smooth UX while keeping accessibility in mind 🪐
https://temzasse.github.io/react-modal-sheet/
MIT License
791 stars 75 forks source link

Animation Not Working in Safari #65

Closed ankur-kunaico closed 1 year ago

ankur-kunaico commented 2 years ago

Using it with FocusTrap


header: {
    opacity: 0,
    [theme.breakpoints.up('xl')]: {
      '& .react-modal-sheet-header': {
        height: '32px !important',
      },
      '& + .react-modal-sheet-content': {
        flex: '0 1 auto !important',
        overflow: 'visible !important',
      },
    },
  },
  content: {
    display: 'flex',
    flexDirection: 'column',
    justifyContent: 'space-between',
    height: '100%',
    [theme.breakpoints.up('xl')]: {
      flexDirection: 'row',
      flexWrap: 'wrap',
    },

<Sheet
        isOpen={props.isOpen}
        onClose={() => props.setOpen(false)}
        snapPoints={width > widthBreakpoint ? [195] : [600]}>
        <Sheet.Container>
          <Sheet.Header className={classes.header} />
          <FocusTrap active={props.isOpen}>
            <Sheet.Content>
         {...Content}
            </Sheet.Content>
          </FocusTrap>
        </Sheet.Container>
        <Sheet.Backdrop />
      </Sheet>

Without Focus Trap Its working as expected ezgif com-gif-maker

Temzasse commented 2 years ago

Interesting 🤔 This is probably due to the fact that I'm mapping over the children and passing them a custom key for AnimatePresence to work properly.

Can you try to put the FocusTrap between Sheet and SheetContainer? I'm doing that in my A11ySheet demo and worked okay.

const Example = () => {
  return (
    <Sheet>
      <FocusTrap>
        <SheetContainer>
          /* ...content... */
        </SheetContainer>
      </FocusTrap>
    </Sheet>
  );
}
stephanschubert commented 2 years ago

@Temzasse I'm using your A11ySheet example but got the same issue.. but removing restoreFocus "fixes" it. Any idea what the culprit could be?

EDIT Just realized FocusScope is from another library https://github.com/adobe/react-spectrum.