Skip to content

Commit 28c3f9d

Browse files
authored
fix: Handled workspace switcher closing on click (#6585)
1 parent 9d01a6d commit 28c3f9d

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

web/core/components/workspace/sidebar/dropdown-item.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ type TProps = {
1919
activeWorkspace: IWorkspace | null;
2020
handleItemClick: () => void;
2121
handleWorkspaceNavigation: (workspace: IWorkspace) => void;
22+
handleClose: () => void;
2223
};
2324
const SidebarDropdownItem = observer((props: TProps) => {
24-
const { workspace, activeWorkspace, handleItemClick, handleWorkspaceNavigation } = props;
25+
const { workspace, activeWorkspace, handleItemClick, handleWorkspaceNavigation, handleClose } = props;
2526
// router
2627
const { workspaceSlug } = useParams();
2728
// hooks
@@ -89,13 +90,15 @@ const SidebarDropdownItem = observer((props: TProps) => {
8990
<div className="mt-2 mb-1 flex gap-2">
9091
<Link
9192
href={`/${workspace.slug}/settings`}
93+
onClick={handleClose}
9294
className="flex border border-custom-border-200 rounded-md py-1 px-2 gap-1 bg-custom-sidebar-background-100 hover:shadow-sm hover:text-custom-text-200 text-custom-text-300 hover:border-custom-border-300 "
9395
>
9496
<Settings className="h-4 w-4 my-auto" />
9597
<span className="text-sm font-medium my-auto">{t("settings")}</span>
9698
</Link>
9799
<Link
98100
href={`/${workspace.slug}/settings/members`}
101+
onClick={handleClose}
99102
className="flex border border-custom-border-200 rounded-md py-1 px-2 gap-1 bg-custom-sidebar-background-100 hover:shadow-sm hover:text-custom-text-200 text-custom-text-300 hover:border-custom-border-300 "
100103
>
101104
<UserPlus className="h-4 w-4 my-auto" />

web/core/components/workspace/sidebar/dropdown.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,10 @@ export const SidebarDropdown = observer(() => {
4646
// popper-js init
4747
const { styles, attributes } = usePopper(referenceElement, popperElement, {
4848
placement: "right",
49-
modifiers: [
50-
{
51-
name: "preventOverflow",
52-
options: {
53-
padding: 12,
54-
},
55-
},
56-
],
49+
modifiers: [{ name: "preventOverflow", options: { padding: 12 } }],
5750
});
5851

59-
const handleWorkspaceNavigation = (workspace: IWorkspace) =>
60-
updateUserProfile({
61-
last_workspace_id: workspace?.id,
62-
});
52+
const handleWorkspaceNavigation = (workspace: IWorkspace) => updateUserProfile({ last_workspace_id: workspace?.id });
6353

6454
const handleSignOut = async () => {
6555
await signOut().catch(() =>
@@ -86,14 +76,12 @@ export const SidebarDropdown = observer(() => {
8676
"flex-grow-0 justify-center": sidebarCollapsed,
8777
})}
8878
>
89-
{({ open }) => (
79+
{({ open, close }) => (
9080
<>
9181
<Menu.Button
9282
className={cn(
9383
"group/menu-button flex items-center justify-between gap-1 p-1 truncate rounded text-sm font-medium text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:outline-none",
94-
{
95-
"flex-grow": !sidebarCollapsed,
96-
}
84+
{ "flex-grow": !sidebarCollapsed }
9785
)}
9886
>
9987
<div className="flex-grow flex items-center gap-2 truncate">
@@ -108,9 +96,7 @@ export const SidebarDropdown = observer(() => {
10896
<ChevronDown
10997
className={cn(
11098
"flex-shrink-0 mx-1 hidden size-4 group-hover/menu-button:block text-custom-sidebar-text-400 duration-300",
111-
{
112-
"rotate-180": open,
113-
}
99+
{ "rotate-180": open }
114100
)}
115101
/>
116102
)}
@@ -145,6 +131,7 @@ export const SidebarDropdown = observer(() => {
145131
activeWorkspace={activeWorkspace}
146132
handleItemClick={handleItemClick}
147133
handleWorkspaceNavigation={handleWorkspaceNavigation}
134+
handleClose={close}
148135
/>
149136
))}
150137
</div>

0 commit comments

Comments
 (0)