Skip to content

Commit a13d8f0

Browse files
dougfabrisabhinavkrin
authored andcommitted
fix: Multi-step modals closing unexpectedly (#33158)
1 parent 459227b commit a13d8f0

File tree

9 files changed

+22
-56
lines changed

9 files changed

+22
-56
lines changed

.changeset/wise-avocados-taste.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/meteor': patch
3+
---
4+
5+
Fixes an issue where multi-step modals were closing unexpectedly

apps/meteor/client/components/GenericModal/GenericModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const GenericModal = ({
111111
{tagline && <Modal.Tagline>{tagline}</Modal.Tagline>}
112112
<Modal.Title id={`${genericModalId}-title`}>{title ?? t('Are_you_sure')}</Modal.Title>
113113
</Modal.HeaderText>
114-
<Modal.Close aria-label={t('Close')} onClick={handleCloseButtonClick} />
114+
{onClose && <Modal.Close aria-label={t('Close')} onClick={handleCloseButtonClick} />}
115115
</Modal.Header>
116116
<Modal.Content fontScale='p2'>{children}</Modal.Content>
117117
<Modal.Footer justifyContent={dontAskAgain ? 'space-between' : 'end'}>
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
import { Skeleton } from '@rocket.chat/fuselage';
2-
import { useTranslation } from '@rocket.chat/ui-contexts';
32
import type { ComponentProps } from 'react';
43
import React from 'react';
54

65
import GenericModal from './GenericModal';
76

8-
const GenericModalSkeleton = ({ onClose, ...props }: ComponentProps<typeof GenericModal>) => {
9-
const t = useTranslation();
10-
11-
return (
12-
<GenericModal
13-
{...props}
14-
variant='warning'
15-
onClose={onClose}
16-
title={<Skeleton width='50%' />}
17-
confirmText={t('Cancel')}
18-
onConfirm={onClose}
19-
>
20-
<Skeleton width='full' />
21-
</GenericModal>
22-
);
23-
};
7+
const GenericModalSkeleton = (props: ComponentProps<typeof GenericModal>) => (
8+
<GenericModal {...props} icon={null} title={<Skeleton width='50%' />}>
9+
<Skeleton width='full' />
10+
</GenericModal>
11+
);
2412

2513
export default GenericModalSkeleton;

apps/meteor/client/views/room/modals/ReadReceiptsModal/ReadReceiptsModal.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { IMessage, ReadReceipt } from '@rocket.chat/core-typings';
2-
import { Skeleton } from '@rocket.chat/fuselage';
32
import { useMethod, useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts';
43
import { useQuery } from '@tanstack/react-query';
54
import type { ReactElement } from 'react';
65
import React, { useEffect } from 'react';
76

87
import GenericModal from '../../../../components/GenericModal';
8+
import GenericModalSkeleton from '../../../../components/GenericModal/GenericModalSkeleton';
99
import ReadReceiptRow from './ReadReceiptRow';
1010

1111
type ReadReceiptsModalProps = {
@@ -29,11 +29,7 @@ const ReadReceiptsModal = ({ messageId, onClose }: ReadReceiptsModalProps): Reac
2929
}, [dispatchToastMessage, t, onClose, readReceiptsResult.isError, readReceiptsResult.error]);
3030

3131
if (readReceiptsResult.isLoading || readReceiptsResult.isError) {
32-
return (
33-
<GenericModal title={t('Read_by')} onConfirm={onClose} onClose={onClose}>
34-
<Skeleton type='rect' w='full' h='x120' />
35-
</GenericModal>
36-
);
32+
return <GenericModalSkeleton />;
3733
}
3834

3935
const readReceipts = readReceiptsResult.data;

apps/meteor/client/views/teams/ConvertToChannelModal/ConvertToChannelModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ConvertToChannelModal = ({ onClose, onCancel, onConfirm, teamId, userId }:
2020
});
2121

2222
if (phase === AsyncStatePhase.LOADING) {
23-
return <GenericModalSkeleton onClose={onClose} />;
23+
return <GenericModalSkeleton />;
2424
}
2525

2626
return <BaseConvertToChannelModal onClose={onClose} onCancel={onCancel} onConfirm={onConfirm} rooms={value?.rooms} />;

apps/meteor/client/views/teams/contextualBar/info/DeleteTeam/DeleteTeamModalWithRooms.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type { IRoom } from '@rocket.chat/core-typings';
2-
import { Skeleton } from '@rocket.chat/fuselage';
3-
import { useTranslation, useEndpoint } from '@rocket.chat/ui-contexts';
2+
import { useEndpoint } from '@rocket.chat/ui-contexts';
43
import { useQuery } from '@tanstack/react-query';
54
import type { ReactElement } from 'react';
65
import React, { useMemo } from 'react';
76

8-
import GenericModal from '../../../../../components/GenericModal';
7+
import GenericModalSkeleton from '../../../../../components/GenericModal/GenericModalSkeleton';
98
import DeleteTeamModal from './DeleteTeamModal';
109

1110
type DeleteTeamModalWithRoomsProps = {
@@ -15,17 +14,12 @@ type DeleteTeamModalWithRoomsProps = {
1514
};
1615

1716
const DeleteTeamModalWithRooms = ({ teamId, onConfirm, onCancel }: DeleteTeamModalWithRoomsProps): ReactElement => {
18-
const t = useTranslation();
1917
const query = useMemo(() => ({ teamId }), [teamId]);
2018
const getTeamsListRooms = useEndpoint('GET', '/v1/teams.listRooms');
2119
const { data, isLoading } = useQuery(['getTeamsListRooms', query], async () => getTeamsListRooms(query));
2220

2321
if (isLoading) {
24-
return (
25-
<GenericModal variant='warning' onClose={onCancel} onConfirm={onCancel} title={<Skeleton width='50%' />} confirmText={t('Cancel')}>
26-
<Skeleton width='full' />
27-
</GenericModal>
28-
);
22+
return <GenericModalSkeleton />;
2923
}
3024
return <DeleteTeamModal onCancel={onCancel} onConfirm={onConfirm} rooms={data?.rooms || []} />;
3125
};

apps/meteor/client/views/teams/contextualBar/info/LeaveTeam/LeaveTeamWithData.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type { ITeam } from '@rocket.chat/core-typings';
2-
import { Skeleton } from '@rocket.chat/fuselage';
3-
import { useUserId, useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
2+
import { useUserId, useEndpoint } from '@rocket.chat/ui-contexts';
43
import { useQuery } from '@tanstack/react-query';
54
import type { ReactElement } from 'react';
65
import React from 'react';
76

8-
import GenericModal from '../../../../../components/GenericModal';
7+
import GenericModalSkeleton from '../../../../../components/GenericModal/GenericModalSkeleton';
98
import LeaveTeamModal from './LeaveTeamModal/LeaveTeamModal';
109

1110
type LeaveTeamWithDataProps = {
@@ -15,7 +14,6 @@ type LeaveTeamWithDataProps = {
1514
};
1615

1716
const LeaveTeamWithData = ({ teamId, onCancel, onConfirm }: LeaveTeamWithDataProps): ReactElement => {
18-
const t = useTranslation();
1917
const userId = useUserId();
2018

2119
if (!userId) {
@@ -26,11 +24,7 @@ const LeaveTeamWithData = ({ teamId, onCancel, onConfirm }: LeaveTeamWithDataPro
2624
const { data, isLoading } = useQuery(['teams.listRoomsOfUser'], () => getRoomsOfUser({ teamId, userId }));
2725

2826
if (isLoading) {
29-
return (
30-
<GenericModal variant='warning' onClose={onCancel} onConfirm={onCancel} title={<Skeleton width='50%' />} confirmText={t('Cancel')}>
31-
<Skeleton width='full' />
32-
</GenericModal>
33-
);
27+
return <GenericModalSkeleton />;
3428
}
3529

3630
return <LeaveTeamModal onCancel={onCancel} onConfirm={onConfirm} rooms={data?.rooms || []} />;

apps/meteor/client/views/teams/contextualBar/members/RemoveUsersModal/RemoveUsersModal.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
import { Skeleton } from '@rocket.chat/fuselage';
2-
import { useTranslation } from '@rocket.chat/ui-contexts';
31
import React, { useMemo } from 'react';
42

5-
import GenericModal from '../../../../../components/GenericModal';
3+
import GenericModalSkeleton from '../../../../../components/GenericModal/GenericModalSkeleton';
64
import { useEndpointData } from '../../../../../hooks/useEndpointData';
75
import { AsyncStatePhase } from '../../../../../lib/asyncState';
86
import BaseRemoveUsersModal from './BaseRemoveUsersModal';
97

108
const initialData = { user: { username: '' } };
119

1210
const RemoveUsersModal = ({ teamId, userId, onClose, onCancel, onConfirm }) => {
13-
const t = useTranslation();
1411
const { value, phase } = useEndpointData('/v1/teams.listRoomsOfUser', { params: useMemo(() => ({ teamId, userId }), [teamId, userId]) });
1512
const userDataFetch = useEndpointData('/v1/users.info', { params: useMemo(() => ({ userId }), [userId]), initialValue: initialData });
1613
const {
1714
user: { username },
1815
} = userDataFetch?.value;
1916

2017
if (phase === AsyncStatePhase.LOADING) {
21-
return (
22-
<GenericModal variant='warning' onClose={onClose} title={<Skeleton width='50%' />} confirmText={t('Cancel')} onConfirm={onClose}>
23-
<Skeleton width='full' />
24-
</GenericModal>
25-
);
18+
return <GenericModalSkeleton />;
2619
}
2720

2821
return <BaseRemoveUsersModal onClose={onClose} username={username} onCancel={onCancel} onConfirm={onConfirm} rooms={value?.rooms} />;

apps/meteor/tests/e2e/team-management.spec.ts

-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ test.describe.serial('teams-management', () => {
116116
});
117117

118118
test('should remove user1 from targetTeamNonPrivate', async () => {
119-
test.fail();
120119
await poHomeTeam.sidenav.openChat(targetTeamNonPrivate);
121120
await poHomeTeam.tabs.kebab.click({ force: true });
122121
await poHomeTeam.tabs.btnTeamMembers.click();
@@ -130,7 +129,6 @@ test.describe.serial('teams-management', () => {
130129
});
131130

132131
test('should delete targetTeamNonPrivate', async () => {
133-
test.fail();
134132
await poHomeTeam.sidenav.openChat(targetTeamNonPrivate);
135133
await poHomeTeam.tabs.btnRoomInfo.click();
136134
await poHomeTeam.tabs.room.btnDelete.click();
@@ -142,7 +140,6 @@ test.describe.serial('teams-management', () => {
142140
});
143141

144142
test('should user1 leave from targetTeam', async ({ browser }) => {
145-
test.fail();
146143
const user1Page = await browser.newPage({ storageState: Users.user1.state });
147144
const user1Channel = new HomeTeam(user1Page);
148145
await user1Page.goto(`/group/${targetTeam}`);
@@ -163,7 +160,6 @@ test.describe.serial('teams-management', () => {
163160
});
164161

165162
test('should convert team into a channel', async ({ page }) => {
166-
test.fail();
167163
await poHomeTeam.sidenav.openChat(targetTeam);
168164
await poHomeTeam.tabs.btnRoomInfo.click();
169165
await poHomeTeam.tabs.room.btnMore.click();

0 commit comments

Comments
 (0)