Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Rework modal to support all client use cases #26

Merged
merged 5 commits into from
Nov 25, 2020

Conversation

raymondjacobson
Copy link
Member

@raymondjacobson raymondjacobson commented Nov 20, 2020

Reworks the modal to support use in protocol-dashboard & audius-client in all use cases. Those relevant PRs are:

audius-client: AudiusProject/audius-client#125
protocol-dashboard: AudiusProject/protocol-dashboard#16

There are three major changes in this PR:

  1. Scroll counting is done internally within the modal now. Although this does break the "single counter" model that we share across the dapp to lock scroll count, I think it's ok for modals afaict. Once all the modals let go of their counter, scrolling is freed up. Works even with multiple modals.

  2. Modals now create their own background / root context. One challenging issue I ran into when integrating this guy into all parts of the dapp is in cases where we have nested modals (e.g. stems modal inside edit track modal), the modals end up kind of canceling each other's backgrounds / root contexts out since they refer to the same dom node and both modals are mounted on the page at the same time. A unique modalKey similar to the scrubber pattern is added here (auto-assigned if not provided, but useful for debugging to provide).

  3. Updates useClickOutside to respect an isException check. This is necessary to allow "useClickOutside" style dismisses to work in the case of nested modals. We never hit this issue in the dapp before because nested modals were always one antd modal and one stems modal so they never clashed in that sense.

Copy link
Contributor

@piazzatron piazzatron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing 🎉
Only nits from me - I didn't check this on stage, but the code all looks great

src/Modal/Modal.tsx Outdated Show resolved Hide resolved
src/hooks/useClickOutside.ts Outdated Show resolved Hide resolved
src/Modal/Modal.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@piazzatron piazzatron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, called out one thing in useGlobal

src/hooks/useGlobal.ts Outdated Show resolved Hide resolved
@raymondjacobson raymondjacobson merged commit 3f17281 into master Nov 25, 2020
@raymondjacobson raymondjacobson deleted the rj-clean-up-modal branch November 25, 2020 00:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants