Skip to content
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

Modal Layering With Top Insets #4616

Open
jfries289 opened this issue Jan 29, 2025 · 0 comments
Open

Modal Layering With Top Insets #4616

jfries289 opened this issue Jan 29, 2025 · 0 comments
Labels

Comments

@jfries289
Copy link

Current behaviour

We use modals in multiple places in our app, with some of them being nested. We share wrapped modal components as well.
We recently switched to using the react-native-paper modal component rather than the react-native one, and now our modals, which should be full screen, are being offset from the top and revealing the views beneath. I have found no way to turn this off, nor have I yet been able to find what is causing it in the react-native-paper code. I am currently attempting to use marginTop on the modals to adjust them, which sort of works, except that the adjustments differ from component to component, and between the same component reused in different places, and between iOS and Android. It's a mess.

Expected behaviour

How to reproduce?

Main modal implementations look like:

return (
    <Portal>
      <Modal
        visible={isVisible}
        onDismiss={() => { closeModal() }}
        contentContainerStyle={styles.modalContentContainer}
        testID="modal-component"
        style={[styles.modal, modalStyleOverride]}   //   <-- modalStyleOverride is passed in  with a marginTop adjustment
        theme={{ isV3: false }}
      >
        <Header ... />
        <View style={[styles.modalBody, addtlViewStyle]}>
          {useScrollView ? <ScrollView>{renderContent()}</ScrollView> : renderContent()}
        </View>
      </Modal>
    </Portal>
  )
...
const styles = StyleSheet.create({
  modal: {
    backgroundColor: colors.background,
    elevation: 0,
  },
  modalContentContainer: {
    flex: 1,
    height: "100%",
    elevation: 0,
    shadowOpacity: 0,
  },
...
})

and

  return (
      <Portal>
        <Modal visible={isVisible} onDismiss={closeModal} style={styles.modal} >
          <View style={styles.pdfViewContainer}>
            <SomeContentView ... />
          </View>
        </Modal>
      </Portal>
    )
}

const styles = StyleSheet.create({
  modal: {
    marginTop: Platform.OS === "ios" ? -64 : 0,
  },

Preview

The marked orange header should not be visible:
Image

What have you tried so far?

Currently using marginTop to adjust, but's it's untenable

Your Environment

software version
ios 17
android 14
react-native 0.73.11
react-native-paper 5.12.3
node 20.8.1
npm or yarn 4.6.0
expo sdk 50.0.21
@jfries289 jfries289 added the bug label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant