From 32d894bf84e6b2839784908cab3e2760beafa28e Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Sun, 27 Jul 2025 22:47:24 -0400 Subject: [PATCH] Migrate ViewReactionsDialog from reakit tabs to radix tabs (#9750) - Replace reakit Tab, TabPanel, useTabState with @radix-ui/react-tabs - Maintain identical styling and behavior - Use Tabs.Root, Tabs.List, Tabs.Trigger, and Tabs.Content components - Add state management for selected tab with React.useState - Preserve all existing styling including hover effects and active tab indicator Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> --- .../Reactions/ViewReactionsDialog.tsx | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/app/components/Reactions/ViewReactionsDialog.tsx b/app/components/Reactions/ViewReactionsDialog.tsx index 8c486fc767..dd0534ac6c 100644 --- a/app/components/Reactions/ViewReactionsDialog.tsx +++ b/app/components/Reactions/ViewReactionsDialog.tsx @@ -2,7 +2,7 @@ import compact from "lodash/compact"; import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; -import { Tab, TabPanel, useTabState } from "reakit"; +import * as Tabs from "@radix-ui/react-tabs"; import { toast } from "sonner"; import styled, { css } from "styled-components"; import { s, hover } from "@shared/styles"; @@ -22,7 +22,9 @@ type Props = { const ViewReactionsDialog: React.FC = ({ model }) => { const { t } = useTranslation(); const { users } = useStores(); - const tab = useTabState(); + const [selectedTab, setSelectedTab] = React.useState( + model.reactions[0]?.emoji || "" + ); const { reactedUsersLoaded } = model; React.useEffect(() => { @@ -37,24 +39,32 @@ const ViewReactionsDialog: React.FC = ({ model }) => { void loadReactedUsersData(); }, [t, model]); + // Set initial tab when reactions are loaded + React.useEffect(() => { + if (model.reactions.length > 0 && !selectedTab) { + setSelectedTab(model.reactions[0].emoji); + } + }, [model.reactions, selectedTab]); + if (!reactedUsersLoaded) { return ; } return ( - <> + - {model.reactions.map((reaction) => ( - - {reaction.emoji} - - ))} + + {model.reactions.map((reaction) => ( + + {reaction.emoji} + + ))} + {model.reactions.map((reaction) => { const reactedUsers = compact( @@ -62,7 +72,7 @@ const ViewReactionsDialog: React.FC = ({ model }) => { ); return ( - + {reactedUsers.map((user) => ( @@ -72,7 +82,7 @@ const ViewReactionsDialog: React.FC = ({ model }) => { ); })} - + ); }; @@ -101,7 +111,7 @@ const TabActionsWrapper = styled(Flex)` border-bottom: 1px solid ${s("inputBorder")}; `; -const StyledTab = styled(Tab)<{ $active: boolean }>` +const StyledTab = styled(Tabs.Trigger)<{ $active: boolean }>` position: relative; font-weight: 500; font-size: 14px; @@ -132,7 +142,7 @@ const StyledTab = styled(Tab)<{ $active: boolean }>` `} `; -const StyledTabPanel = styled(TabPanel)` +const StyledTabPanel = styled(Tabs.Content)` height: 300px; padding: 5px 0; overflow-y: auto;