From 8f0e4dae9dab0baf8ae712af14dd7abc5b3603df Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 14 Aug 2020 12:01:16 +0100 Subject: [PATCH 1/2] Allow room tile context menu when minimized using right click --- .../views/elements/AccessibleTooltipButton.tsx | 10 ++++++++++ src/components/views/rooms/RoomTile.tsx | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/AccessibleTooltipButton.tsx b/src/components/views/elements/AccessibleTooltipButton.tsx index 3546f62359..0388c565ad 100644 --- a/src/components/views/elements/AccessibleTooltipButton.tsx +++ b/src/components/views/elements/AccessibleTooltipButton.tsx @@ -25,6 +25,7 @@ interface ITooltipProps extends React.ComponentProps { title: string; tooltip?: React.ReactNode; tooltipClassName?: string; + forceHide?: boolean; } interface IState { @@ -39,7 +40,16 @@ export default class AccessibleTooltipButton extends React.PureComponent) { + if (!prevProps.forceHide && this.props.forceHide && this.state.hover) { + this.setState({ + hover: false, + }); + } + } + onMouseOver = () => { + if (this.props.forceHide) return; this.setState({ hover: true, }); diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx index 09f201e3ef..0c99b98e1a 100644 --- a/src/components/views/rooms/RoomTile.tsx +++ b/src/components/views/rooms/RoomTile.tsx @@ -113,7 +113,7 @@ export default class RoomTile extends React.PureComponent { }; private get showContextMenu(): boolean { - return !this.props.isMinimized && this.props.tag !== DefaultTagID.Invite; + return this.props.tag !== DefaultTagID.Invite; } private get showMessagePreview(): boolean { @@ -304,7 +304,9 @@ export default class RoomTile extends React.PureComponent { private onClickMute = ev => this.saveNotifState(ev, MUTE); private renderNotificationsMenu(isActive: boolean): React.ReactElement { - if (MatrixClientPeg.get().isGuest() || this.props.tag === DefaultTagID.Archived || !this.showContextMenu) { + if (MatrixClientPeg.get().isGuest() || this.props.tag === DefaultTagID.Archived || + !this.showContextMenu || this.props.isMinimized + ) { // the menu makes no sense in these cases so do not show one return null; } @@ -530,9 +532,13 @@ export default class RoomTile extends React.PureComponent { ariaDescribedBy = messagePreviewId(this.props.room.roomId); } + const props: Partial> = {}; let Button: React.ComponentType> = AccessibleButton; if (this.props.isMinimized) { Button = AccessibleTooltipButton; + props.title = name; + // force the tooltip to hide whilst we are showing the context menu + props.forceHide = !!this.state.generalMenuPosition; } return ( @@ -540,6 +546,7 @@ export default class RoomTile extends React.PureComponent { {({onFocus, isActive, ref}) =>