Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions packages/ui/src/layout/MainLayout/LogoSection/index.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import { Link } from 'react-router-dom'
import { useDispatch } from 'react-redux'

// material-ui
import { ButtonBase } from '@mui/material'

// project imports
import config from '@/config'
import Logo from '@/ui-component/extended/Logo'
import { MENU_OPEN } from '@/store/actions'

// ==============================|| MAIN LOGO ||============================== //

const LogoSection = () => (
<ButtonBase disableRipple component={Link} to={config.defaultPath}>
<Logo />
</ButtonBase>
)
const LogoSection = () => {
const dispatch = useDispatch()

const handleLogoClick = (e) => {
dispatch({ type: MENU_OPEN, id: 'chatflows' })
}
Comment on lines +17 to +19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When a user performs a modified click (such as Cmd/Ctrl + Click) or a middle-click on the logo to open the link in a new tab, the onClick handler still executes in the current tab. This causes the sidebar active state to unexpectedly change to 'chatflows' in the current tab, even though no navigation occurred there.

To prevent this, we should ignore clicks that are modified or not performed with the primary (left) mouse button.

Suggested change
const handleLogoClick = (e) => {
dispatch({ type: MENU_OPEN, id: 'chatflows' })
}
const handleLogoClick = (e) => {
if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return
dispatch({ type: MENU_OPEN, id: 'chatflows' })
}


return (
<ButtonBase disableRipple component={Link} to={config.defaultPath} onClick={handleLogoClick}>
<Logo />
</ButtonBase>
)
Comment on lines +17 to +25
}

export default LogoSection