diff --git a/apps/meteor/client/views/room/components/body/RoomBody.tsx b/apps/meteor/client/views/room/components/body/RoomBody.tsx index 08ff067bb86a..1d783e7432bc 100644 --- a/apps/meteor/client/views/room/components/body/RoomBody.tsx +++ b/apps/meteor/client/views/room/components/body/RoomBody.tsx @@ -11,7 +11,7 @@ import { useUser, useUserPreference, } from '@rocket.chat/ui-contexts'; -import type { ReactElement, UIEvent } from 'react'; +import type { MouseEventHandler, ReactElement, UIEvent } from 'react'; import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useSyncExternalStore } from 'use-sync-external-store/shim'; @@ -532,6 +532,21 @@ const RoomBody = (): ReactElement => { chat.uploads.wipeFailedOnes(); }, [chat]); + const handleCloseFlexTab: MouseEventHandler = useCallback( + (e): void => { + if (!hideFlexTab) { + return; + } + + if (e.target instanceof HTMLButtonElement) { + return; + } + + toolbox.close(); + }, + [toolbox, hideFlexTab], + ); + return ( <> {!isLayoutEmbedded && room.announcement && } @@ -540,7 +555,7 @@ const RoomBody = (): ReactElement => { className={`messages-container flex-tab-main-content ${admin ? 'admin' : ''}`} id={`chat-window-${room._id}`} aria-label={t('Channel')} - onClick={hideFlexTab ? toolbox.close : undefined} + onClick={handleCloseFlexTab} >
diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index c32557e7ddfd..879d6cba8555 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2350,7 +2350,7 @@ "Hidden": "Hidden", "Hide": "Hide", "Hide_counter": "Hide counter", - "Hide_flextab": "Hide Right Sidebar with Click", + "Hide_flextab": "Hide Contextual Bar by clicking outside of it", "Hide_Group_Warning": "Are you sure you want to hide the group \"%s\"?", "Hide_Livechat_Warning": "Are you sure you want to hide the chat with \"%s\"?", "Hide_Private_Warning": "Are you sure you want to hide the discussion with \"%s\"?", diff --git a/apps/meteor/tests/e2e/message-actions.spec.ts b/apps/meteor/tests/e2e/message-actions.spec.ts index 5ca96bb23761..23d77f54a60b 100644 --- a/apps/meteor/tests/e2e/message-actions.spec.ts +++ b/apps/meteor/tests/e2e/message-actions.spec.ts @@ -84,7 +84,7 @@ test.describe.serial('message-actions', () => { await page.locator('[data-qa-id="permalink"]').click(); }); - test.describe('Preference Hide Right Sidebar with Click Enabled', () => { + test.describe('Preference Hide Contextual Bar by clicking outside of it Enabled', () => { let adminPage: Page; test.beforeAll(async ({ browser }) => { @@ -92,7 +92,7 @@ test.describe.serial('message-actions', () => { await adminPage.goto('/account/preferences'); await adminPage.locator('role=heading[name="Messages"]').click(); - await adminPage.locator('text="Hide Right Sidebar with Click"').click(); + await adminPage.locator('text="Hide Contextual Bar by clicking outside of it"').click(); }); test.afterAll(async ({ browser }) => { @@ -100,7 +100,7 @@ test.describe.serial('message-actions', () => { await adminPage.goto('/account/preferences'); await adminPage.locator('role=heading[name="Messages"]').click(); - await adminPage.locator('text="Hide Right Sidebar with Click"').click(); + await adminPage.locator('text="Hide Contextual Bar by clicking outside of it"').click(); await adminPage.close(); });