Skip to content

Commit 5010b36

Browse files
fix: Export Messages tab closing due to "flex-tab close when click outside of it" preference (#36812)
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
1 parent 37bb227 commit 5010b36

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

.changeset/fluffy-dryers-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rocket.chat/meteor": patch
3+
---
4+
5+
Prevent `Export Messages` tab from closing when selecting messages by clicking outside of it and preference "Hide Contextual Bar by clicking outside of it" is set true.

apps/meteor/client/views/room/MessageList/contexts/SelectedMessagesContext.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { FormEvent } from 'react';
12
import { createContext, useCallback, useContext, useEffect, useSyncExternalStore } from 'react';
23

34
import { selectedMessageStore } from '../../providers/SelectedMessagesProvider';
@@ -48,11 +49,16 @@ export const useIsSelecting = (): boolean => {
4849
return useSyncExternalStore(subscribe, getSnapshot);
4950
};
5051

51-
export const useToggleSelect = (mid: string): (() => void) => {
52+
export const useToggleSelect = (mid: string): ((event?: FormEvent<HTMLElement>) => void) => {
5253
const { selectedMessageStore } = useContext(SelectedMessageContext);
53-
return useCallback(() => {
54-
selectedMessageStore.toggle(mid);
55-
}, [mid, selectedMessageStore]);
54+
55+
return useCallback(
56+
(event) => {
57+
event?.stopPropagation();
58+
selectedMessageStore.toggle(mid);
59+
},
60+
[mid, selectedMessageStore],
61+
);
5662
};
5763

5864
export const useToggleSelectAll = (): (() => void) => {

apps/meteor/tests/e2e/export-messages.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ test.describe('export-messages', () => {
145145
await expect(exportMessagesTab.sendButton).toBeEnabled();
146146
});
147147

148-
// TODO: Fix this test - the test is failing because when selecting the message, the import messages tab becomes not visible
149-
// and the message is not selected.
150-
test.fail('should be able to select a single message to export with hide contextual bar preference enabled', async ({ page, api }) => {
148+
test('should be able to select a single message to export with hide contextual bar preference enabled', async ({ page, api }) => {
151149
await api.post('/users.setPreferences', {
152150
userId: 'rocketchat.internal.admin.test',
153151
data: { hideFlexTab: true },

0 commit comments

Comments
 (0)