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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.
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).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.