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

chore: HeaderState receiving invalid prop #35612

Merged
merged 3 commits into from
Mar 25, 2025
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
1 change: 1 addition & 0 deletions apps/meteor/client/views/room/Header/RoomTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const RoomTitle = ({ room }: { room: IRoom }): ReactElement => {
onClick={() => handleOpenRoomInfo()}
tabIndex={0}
role='button'
mie={4}
>
<HeaderIconWithRoom room={room} />
<HeaderTitle is='h1'>{room.name}</HeaderTitle>
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/client/views/room/Header/icons/Favorite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const Favorite = ({ room: { _id, f: favorite = false, t: type, name } }: { room:
title={favoriteLabel}
icon={favorite ? 'star-filled' : 'star'}
onClick={handleFavoriteClick}
color={favorite ? 'status-font-on-warning' : null}
tiny
color={favorite ? 'status-font-on-warning' : undefined}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/client/views/room/HeaderV2/RoomTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const RoomTitle = ({ room }: RoomTitleProps) => {
onClick={() => handleOpenRoomInfo()}
tabIndex={0}
role='button'
mie={4}
>
<HeaderIconWithRoom room={room} />
<HeaderTitle is='h1'>{room.name}</HeaderTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HeaderState } from '../../../../components/Header';
const Encrypted = ({ room }: { room: IRoom }) => {
const { t } = useTranslation();
const e2eEnabled = useSetting('E2E_Enable');
return e2eEnabled && room?.encrypted ? <HeaderState title={t('Encrypted')} icon='key' color={colors.g500} tiny /> : null;
return e2eEnabled && room?.encrypted ? <HeaderState title={t('Encrypted')} icon='key' color={colors.g500} /> : null;
};

export default memo(Encrypted);
3 changes: 1 addition & 2 deletions apps/meteor/client/views/room/HeaderV2/icons/Favorite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const Favorite = ({ room: { _id, f: favorite = false, t: type, name } }: { room:
title={favoriteLabel}
icon={favorite ? 'star-filled' : 'star'}
onClick={handleFavoriteClick}
color={favorite ? 'status-font-on-warning' : null}
tiny
color={favorite ? 'status-font-on-warning' : undefined}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/channel-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test.describe.serial('channel-management', () => {
targetChannel = hugeName;

await page.setViewportSize({ width: 640, height: 460 });
await expect(page.getByRole('heading', { name: hugeName })).toHaveCSS('width', '419px');
await expect(page.getByRole('heading', { name: hugeName })).toHaveCSS('width', '411px');
});

test('should open sidebar clicking on sidebar toggler', async ({ page }) => {
Expand Down
15 changes: 13 additions & 2 deletions packages/ui-client/src/components/Header/HeaderState.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { Icon, IconButton } from '@rocket.chat/fuselage';
import type { FC } from 'react';
import type { Keys as IconName } from '@rocket.chat/icons';
import type { AllHTMLAttributes, ComponentPropsWithoutRef, FC, MouseEventHandler } from 'react';

const HeaderState: FC<any> = (props) => (props.onClick ? <IconButton mini {...props} /> : <Icon size='x16' name={props.icon} {...props} />);
type HeaderStateProps =
| (Pick<ComponentPropsWithoutRef<typeof IconButton>, 'color' | 'title' | 'icon'> & {
onClick: MouseEventHandler;
} & Omit<AllHTMLAttributes<HTMLButtonElement>, 'is'>)
| (Omit<ComponentPropsWithoutRef<typeof Icon>, 'name' | 'onClick'> & {
icon: IconName;
onClick?: undefined;
});

const HeaderState: FC<HeaderStateProps> = (props) =>
props.onClick ? <IconButton mini mie={4} {...props} /> : <Icon size='x16' mie={4} name={props.icon} {...props} />;

export default HeaderState;
8 changes: 4 additions & 4 deletions packages/ui-client/src/components/HeaderV2/HeaderState.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Icon, IconButton } from '@rocket.chat/fuselage';
import type { Keys as IconName } from '@rocket.chat/icons';
import type { ComponentPropsWithoutRef, MouseEventHandler } from 'react';
import type { AllHTMLAttributes, ComponentPropsWithoutRef, MouseEventHandler } from 'react';

type HeaderStateProps =
| (Omit<ComponentPropsWithoutRef<typeof IconButton>, 'onClick'> & {
| (Pick<ComponentPropsWithoutRef<typeof IconButton>, 'color' | 'title' | 'icon'> & {
onClick: MouseEventHandler;
})
} & Omit<AllHTMLAttributes<HTMLButtonElement>, 'is'>)
| (Omit<ComponentPropsWithoutRef<typeof Icon>, 'name' | 'onClick'> & {
icon: IconName;
onClick?: undefined;
});

const HeaderState = (props: HeaderStateProps) =>
props.onClick ? <IconButton mini {...props} /> : <Icon size='x16' name={props.icon} {...props} />;
props.onClick ? <IconButton mini mie={4} {...props} /> : <Icon size='x16' mie={4} name={props.icon} {...props} />;

export default HeaderState;
Loading