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

Regression: fix close flextab on click outside the container #27857

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 17 additions & 2 deletions apps/meteor/client/views/room/components/body/RoomBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -532,6 +532,21 @@ const RoomBody = (): ReactElement => {
chat.uploads.wipeFailedOnes();
}, [chat]);

const handleCloseFlexTab: MouseEventHandler<HTMLElement> = useCallback(
(e): void => {
if (!hideFlexTab) {
return;
}

if (e.target instanceof HTMLButtonElement) {
return;
}

toolbox.close();
},
[toolbox, hideFlexTab],
);

return (
<>
{!isLayoutEmbedded && room.announcement && <Announcement announcement={room.announcement} announcementDetails={undefined} />}
Expand All @@ -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}
>
<div className='messages-container-wrapper'>
<div className='messages-container-main' {...fileUploadTriggerProps}>
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"?",
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/tests/e2e/message-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ 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 }) => {
adminPage = await browser.newPage({ storageState: 'admin-session.json' });

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 }) => {
adminPage = await browser.newPage({ storageState: 'admin-session.json' });

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();
});

Expand Down