-
Notifications
You must be signed in to change notification settings - Fork 292
feat: add support for global modal rendering at the top of the chat component tree #2792
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
base: master
Are you sure you want to change the base?
Conversation
Size Change: +6 kB (+0.54%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2792 +/- ##
==========================================
+ Coverage 81.21% 81.28% +0.07%
==========================================
Files 487 488 +1
Lines 9785 9893 +108
Branches 2215 2243 +28
==========================================
+ Hits 7947 8042 +95
- Misses 1728 1740 +12
- Partials 110 111 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
<button | ||
className='str-chat__modal__close-button' | ||
ref={closeRef} | ||
title={t('Close')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add type="button"
so this doesn't accidentally submit parent forms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done: 878e855
src/components/Modal/GlobalModal.tsx
Outdated
if (open && !dialog.isOpen) { | ||
dialog.open(); | ||
} | ||
}, [dialog, open, children]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are children
required in the dependency array? This would make this effect run on every re-render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why I put it there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: 371670f
[id], | ||
); | ||
|
||
addDialogManager(dialogManager); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this go inside the useEffect
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
running it inside the effect makes this code to execute later than the children that try to access the manager during the render. addDialogManager
does nothing if the manager exists so it does not cause any harm, but makes sure that children rendering below have the manager available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, why don't children access it via the context provider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is access through the provider - which is the fallback if manager id or dialog id are not specified. If you have a component rendered under two dialog manager providers and the component wants the top level manager, then here we circumvent the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still feels like an anti-pattern. Can we structure this differently so we keep the DialogManagerProvider render pure?
🎯 Goal
Allow to render the modal at the top of chat app.
Fixes REACT-22
Fixes REACT-340
Fixes the issue of modal overlay being cut-off in Safari because the parent was the message thus limiting the overlay position fixed to the message list.
Depends on CSS adjustments: GetStream/stream-chat-css#341
This is an opt-in feature. The top-level modal rendering is activated by passing
GlobalModal
toChannel
and thus theComponentContext
:🛠 Implementation details
The PR introduces possibility of nested
DialogManagerProviders
(Modal > MessageList) and thus allowing to retrieve a dialog manager other than the one from the nearest dialog manager context.🎨 UI Changes
None
Docs
https://github.com/GetStream/docs-content/pull/519