Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix spotlight opening in TAC
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Mar 5, 2024
1 parent 6eafe0e commit 0e7b7b8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 32 deletions.
4 changes: 4 additions & 0 deletions res/css/structures/_ThreadsActivityCentre.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* /
*/

.mx_ThreadsActivityCentre_container {
display: flex;
}

.mx_ThreadsActivityCentreButton {
border-radius: 8px;
margin: 18px auto auto auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import { useUnreadThreadRooms } from "./useUnreadThreadRooms";
import { StatelessNotificationBadge } from "../../rooms/NotificationBadge/StatelessNotificationBadge";
import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel";
import PosthogTrackers from "../../../../PosthogTrackers";
import { RovingTabIndexProvider } from "../../../../accessibility/RovingTabIndex";
import { getKeyBindingsManager } from "../../../../KeyBindingsManager";
import { KeyBindingAction } from "../../../../accessibility/KeyboardShortcuts";

interface ThreadsActivityCentreProps {
/**
Expand All @@ -49,41 +52,56 @@ export function ThreadsActivityCentre({ displayButtonLabel }: ThreadsActivityCen
const roomsAndNotifications = useUnreadThreadRooms(open);

return (
<Menu
align="end"
open={open}
onOpenChange={(newOpen) => {
// Track only when the Threads Activity Centre is opened
if (newOpen) PosthogTrackers.trackInteraction("WebThreadsActivityCentreButton");
<RovingTabIndexProvider
onKeyDown={(evt) => {
const action = getKeyBindingsManager().getNavigationAction(evt);

setOpen(newOpen);
// Block spotlight opening
if (action === KeyBindingAction.FilterRooms) {
evt.stopPropagation();
}
}}
side="right"
title={_t("threads_activity_centre|header")}
trigger={
<ThreadsActivityCentreButton
displayLabel={displayButtonLabel}
notificationLevel={roomsAndNotifications.greatestNotificationLevel}
/>
}
>
{/* Make the content of the pop-up scrollable */}
<div className="mx_ThreadsActivity_rows">
{roomsAndNotifications.rooms.map(({ room, notificationLevel }) => (
<ThreadsActivityRow
key={room.roomId}
room={room}
notificationLevel={notificationLevel}
onClick={() => setOpen(false)}
/>
))}
{roomsAndNotifications.rooms.length === 0 && (
<div className="mx_ThreadsActivityCentre_emptyCaption">
{_t("threads_activity_centre|no_rooms_with_unreads_threads")}
</div>
)}
</div>
</Menu>
{({ onKeyDownHandler }) => (
<div className="mx_ThreadsActivityCentre_container" onKeyDown={onKeyDownHandler}>
<Menu
align="end"
open={open}
onOpenChange={(newOpen) => {
// Track only when the Threads Activity Centre is opened
if (newOpen) PosthogTrackers.trackInteraction("WebThreadsActivityCentreButton");

setOpen(newOpen);
}}
side="right"
title={_t("threads_activity_centre|header")}
trigger={
<ThreadsActivityCentreButton
displayLabel={displayButtonLabel}
notificationLevel={roomsAndNotifications.greatestNotificationLevel}
/>
}
>
{/* Make the content of the pop-up scrollable */}
<div className="mx_ThreadsActivity_rows">
{roomsAndNotifications.rooms.map(({ room, notificationLevel }) => (
<ThreadsActivityRow
key={room.roomId}
room={room}
notificationLevel={notificationLevel}
onClick={() => setOpen(false)}
/>
))}
{roomsAndNotifications.rooms.length === 0 && (
<div className="mx_ThreadsActivityCentre_emptyCaption">
{_t("threads_activity_centre|no_rooms_with_unreads_threads")}
</div>
)}
</div>
</Menu>
</div>
)}
</RovingTabIndexProvider>
);
}

Expand Down

0 comments on commit 0e7b7b8

Please sign in to comment.