fix: Handled workspace switcher closing on click (#6585)
This commit is contained in:
parent
9d01a6d5d7
commit
28c3f9d0cc
2 changed files with 10 additions and 20 deletions
|
|
@ -19,9 +19,10 @@ type TProps = {
|
|||
activeWorkspace: IWorkspace | null;
|
||||
handleItemClick: () => void;
|
||||
handleWorkspaceNavigation: (workspace: IWorkspace) => void;
|
||||
handleClose: () => void;
|
||||
};
|
||||
const SidebarDropdownItem = observer((props: TProps) => {
|
||||
const { workspace, activeWorkspace, handleItemClick, handleWorkspaceNavigation } = props;
|
||||
const { workspace, activeWorkspace, handleItemClick, handleWorkspaceNavigation, handleClose } = props;
|
||||
// router
|
||||
const { workspaceSlug } = useParams();
|
||||
// hooks
|
||||
|
|
@ -89,6 +90,7 @@ const SidebarDropdownItem = observer((props: TProps) => {
|
|||
<div className="mt-2 mb-1 flex gap-2">
|
||||
<Link
|
||||
href={`/${workspace.slug}/settings`}
|
||||
onClick={handleClose}
|
||||
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 "
|
||||
>
|
||||
<Settings className="h-4 w-4 my-auto" />
|
||||
|
|
@ -96,6 +98,7 @@ const SidebarDropdownItem = observer((props: TProps) => {
|
|||
</Link>
|
||||
<Link
|
||||
href={`/${workspace.slug}/settings/members`}
|
||||
onClick={handleClose}
|
||||
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 "
|
||||
>
|
||||
<UserPlus className="h-4 w-4 my-auto" />
|
||||
|
|
|
|||
|
|
@ -46,20 +46,10 @@ export const SidebarDropdown = observer(() => {
|
|||
// popper-js init
|
||||
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
||||
placement: "right",
|
||||
modifiers: [
|
||||
{
|
||||
name: "preventOverflow",
|
||||
options: {
|
||||
padding: 12,
|
||||
},
|
||||
},
|
||||
],
|
||||
modifiers: [{ name: "preventOverflow", options: { padding: 12 } }],
|
||||
});
|
||||
|
||||
const handleWorkspaceNavigation = (workspace: IWorkspace) =>
|
||||
updateUserProfile({
|
||||
last_workspace_id: workspace?.id,
|
||||
});
|
||||
const handleWorkspaceNavigation = (workspace: IWorkspace) => updateUserProfile({ last_workspace_id: workspace?.id });
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await signOut().catch(() =>
|
||||
|
|
@ -86,14 +76,12 @@ export const SidebarDropdown = observer(() => {
|
|||
"flex-grow-0 justify-center": sidebarCollapsed,
|
||||
})}
|
||||
>
|
||||
{({ open }) => (
|
||||
{({ open, close }) => (
|
||||
<>
|
||||
<Menu.Button
|
||||
className={cn(
|
||||
"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",
|
||||
{
|
||||
"flex-grow": !sidebarCollapsed,
|
||||
}
|
||||
{ "flex-grow": !sidebarCollapsed }
|
||||
)}
|
||||
>
|
||||
<div className="flex-grow flex items-center gap-2 truncate">
|
||||
|
|
@ -108,9 +96,7 @@ export const SidebarDropdown = observer(() => {
|
|||
<ChevronDown
|
||||
className={cn(
|
||||
"flex-shrink-0 mx-1 hidden size-4 group-hover/menu-button:block text-custom-sidebar-text-400 duration-300",
|
||||
{
|
||||
"rotate-180": open,
|
||||
}
|
||||
{ "rotate-180": open }
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -145,6 +131,7 @@ export const SidebarDropdown = observer(() => {
|
|||
activeWorkspace={activeWorkspace}
|
||||
handleItemClick={handleItemClick}
|
||||
handleWorkspaceNavigation={handleWorkspaceNavigation}
|
||||
handleClose={close}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue