eBay / eBay/nice-modal-react

Problem with nested NiceModal Provider

Open
#100 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
127
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce

  1. Wrap the whole app with a NiceModal.Provider
  2. Then use react-router or simple state to create 2 page
  3. On page 1 use NiceModal.Provider to wrap all children
  4. Add a button and simple Modal for page 1
  5. On page 2 don't wrap it with a NiceModal.Provider
  6. Add a button and simple Modal for page 2
  7. Add buttons to switch between pages
  8. Start the app

Case 1:

  • Go to page 1 directly then click the button to open the dialog -> it works
  • Go to page 2 by clicking the button we add in step 7 above then click the button to open the dialog -> it doesn't work

Case 2:

  • Go to page 2 directly then click the button to open the dialog -> it works
  • Go to page 1 by clicking the button we add in step 7 then click the button to open the dialog -> it works
  • Go to page 2 by clicking the button we add in step 7 then click the button to open the dialog -> it doesn't work

Github repository

https://github.com/quangphuchuynh95/test-nice-modal

Codesandbox

https://codesandbox.io/s/wizardly-goldberg-rp3vtz?file=/src/index.js

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start by reproducing the nested-provider behavior in the linked GitHub repository or CodeSandbox, following the two cases described in the issue. Trace how page transitions and NiceModal.Provider nesting affect modal opening; done means dialogs open consistently on both pages regardless of navigation order.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.