[Bug?] ModalBottomSheet loses contexts

Open
#61 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
react-native, typescript
Domain
mobile

Research direction

Start by tracing the ModalBottomSheet path used when nativeOverlay is false, focusing on the custom in-library Portal implementation that reparents the sheet. Reproduce the context-loss example, then determine whether context preservation or documenting the limitation is the intended outcome; compare the behavior with react-native-teleport if that alternative is evaluated.

Written by the indexing model from the issue text.

Description

enhancement

ModalBottomSheet (when not nativeOverlay) seems to use a custom in-library Portal implementation that reparents the sheet into a different tree, this makes child components/tree unable to use existing context from the tree.

// psuedocode
const Cx = createContext();

const SheetUser = () => {
  return (
    <Cx value={1}>
      <ModalBottomSheet ...>
         <Inner />
      </ModalBottomSheet>
    </Cx>
  )
}

const Inner = () => {
  const value = useContext(Cx)
  // value is always undefined
  return ...
}

This should either be documented on the documentation or it could be solved by using a library such as react-native-teleport

PS. I came across this issue while trying to add keyboard avoidance to a nativeOverlay modal sheet, and it does not seem to be really possible - keyboard state is undetectable inside the sheet. Should I make another issue for that?

Dominant language
Kotlin
Stars
536
Forks
24
Avg merge
12h 10m
Merged PRs (30d)
22

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from software-mansion/react-native-bottom-sheet

All issues in software-mansion/react-native-bottom-sheet

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.