Skip to content
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

feat: add centralized dialog management #2489

Merged
merged 33 commits into from
Sep 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9751e15
feat: add centralized dialog management
MartinCupela Sep 4, 2024
eb6ab99
Merge branch 'release-v11' into feat/dialogs-manager
MartinCupela Sep 5, 2024
143555b
feat: use own anchor root for DialogAnchor
MartinCupela Sep 5, 2024
c3ed317
feat: forward custom DialogsManager id via DialogsManagerProvider
MartinCupela Sep 5, 2024
71c7685
feat: apply dialogs manager to message lists only
MartinCupela Sep 5, 2024
8e48860
fix: do not forward prop mine to MessageActionsBox root div
MartinCupela Sep 5, 2024
223ddea
test: fix MessageActions tests
MartinCupela Sep 5, 2024
d45459b
test: fix tests rendering message actions
MartinCupela Sep 5, 2024
ba89493
feat: assign static id to DialogsManager inside MessageList
MartinCupela Sep 5, 2024
993358f
docs: fix todo comment
MartinCupela Sep 5, 2024
b557e25
feat: handle focus within dialog
MartinCupela Sep 5, 2024
0a14548
feat: prevent rendering dialog contents if not open
MartinCupela Sep 6, 2024
07eb261
refactor: do not register event listeners by MessageActions component
MartinCupela Sep 6, 2024
d9f3709
test: open MessageActionsBox first in MessageActionsBox.test.js
MartinCupela Sep 6, 2024
af6b94b
feat: control ReactionsSelector dialog display
MartinCupela Sep 6, 2024
8d1c98a
fix: close MessageActionsBox on click inside
MartinCupela Sep 9, 2024
9f071e4
test: add DialogManager tests
MartinCupela Sep 9, 2024
9d1ee9d
refactor: unmound popper element if closed in useDialogAnchor
MartinCupela Sep 9, 2024
86b4cb0
Merge branch 'feat/dialogs-manager'
MartinCupela Sep 9, 2024
d1e4df4
refactor: use StateStore to handle DialogsManager subscriptions
MartinCupela Sep 10, 2024
f76cc75
refactor: rename DialogsManager to DialogManager
MartinCupela Sep 11, 2024
cb52d15
refactor: rename DialogsManager.open param single to closeRest
MartinCupela Sep 11, 2024
45c5eb7
refactor: rename DialogsManager.state.dialogs to DialogsManager.state…
MartinCupela Sep 11, 2024
401af81
refactor: move useStateStore to src/store/hooks
MartinCupela Sep 11, 2024
4f120a4
refactor: remove openDialogCount from DialogManager
MartinCupela Sep 11, 2024
a344533
refactor: apply suggestions about declaring state selector
MartinCupela Sep 11, 2024
1447022
Merge branch 'master' into feat/dialog-manager
MartinCupela Sep 11, 2024
a212d27
fix: remove unsupported onClick prop from ReactionListProps
MartinCupela Sep 11, 2024
9932001
docs: remove references to removed props
MartinCupela Sep 11, 2024
7b32ea3
docs: add dialog management guide and migration guide
MartinCupela Sep 11, 2024
f649140
chore(docs): bump stream-chat-css to v5.0.0-rc.6
MartinCupela Sep 13, 2024
7a67c03
refactor: merge Dialog.toggleOpen and Dialog.toggleOpenSingle into Di…
MartinCupela Sep 16, 2024
580b2bf
Merge branch 'master' into feat/dialog-manager
MartinCupela Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: unmound popper element if closed in useDialogAnchor
MartinCupela committed Sep 9, 2024

Verified

This commit was signed with the committer’s verified signature.
nickzelei Nick Zelei
commit 9d1ee9d089def5350d8e3332c282ff1207bdb470
11 changes: 4 additions & 7 deletions src/components/Dialog/DialogAnchor.tsx
Original file line number Diff line number Diff line change
@@ -42,6 +42,10 @@ export function useDialogAnchor<T extends HTMLElement>({
}
}, [open, popperElement, update]);

if (popperElement && !open) {
setPopperElement(null);
}

return {
attributes,
setPopperElement,
@@ -87,13 +91,6 @@ export const DialogAnchor = ({
};
}, [dialog, open]);

useEffect(() => {
if (!open) {
// setting element reference back to null allows to re-run the usePopper component once the component is re-rendered
setPopperElement(null);
}
}, [open, setPopperElement]);

// prevent rendering the dialog contents if the dialog should not be open / shown
if (!open) {
return null;

Unchanged files with check annotations Beta

id,
isOpen: false,
open: () => {
this.open({ id });

Check warning on line 58 in src/components/Dialog/DialogsManager.ts

Codecov / codecov/patch

src/components/Dialog/DialogsManager.ts#L58

Added line #L58 was not covered by tests
},
remove: () => {
this.remove(id);

Check warning on line 61 in src/components/Dialog/DialogsManager.ts

Codecov / codecov/patch

src/components/Dialog/DialogsManager.ts#L61

Added line #L61 was not covered by tests
},
toggle: () => {
this.toggleOpen({ id });

Check warning on line 64 in src/components/Dialog/DialogsManager.ts

Codecov / codecov/patch

src/components/Dialog/DialogsManager.ts#L64

Added line #L64 was not covered by tests
},
toggleSingle: () => {
this.toggleOpenSingle({ id });
) {
if (dialogsManagerEvents.includes(eventType as DialogsManagerEvent['type'])) {
if (!this.dialogsManagerEventListeners[eventType as DialogsManagerEvent['type']]?.length)
return;

Check warning on line 108 in src/components/Dialog/DialogsManager.ts

Codecov / codecov/patch

src/components/Dialog/DialogsManager.ts#L108

Added line #L108 was not covered by tests
this.dialogsManagerEventListeners[
eventType as DialogsManagerEvent['type']
}
if (nextProps.closeReactionSelectorOnClick !== prevProps.closeReactionSelectorOnClick) {
return false;

Check warning on line 318 in src/components/Message/utils.tsx

Codecov / codecov/patch

src/components/Message/utils.tsx#L318

Added line #L318 was not covered by tests
}
const messagesAreEqual = areMessagesEqual(prevMessage, nextMessage);
if (reaction.type === type) {
return reaction.user?.name || reaction.user?.id;
}
return null;

Check warning on line 128 in src/components/Reactions/ReactionSelector.tsx

Codecov / codecov/patch

src/components/Reactions/ReactionSelector.tsx#L128

Added line #L128 was not covered by tests
})
.filter(Boolean);