Try to fix submenu postition
Signed-off-by: Rodrigo Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
c459997cd9
commit
f6797ebca8
1 file changed
+18
-10
@@ -114,6 +114,13 @@ export const MainLayout: React.FC = () => {
|
|||||||
return location.pathname.startsWith(path);
|
return location.pathname.startsWith(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Adicione esta função dentro do componente MainLayout antes do return
|
||||||
|
const handleMenuHover = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
const menuItem = e.currentTarget;
|
||||||
|
const rect = menuItem.getBoundingClientRect();
|
||||||
|
document.documentElement.style.setProperty('--menu-item-top', `${rect.top}px`);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen bg-gray-100 dark:bg-gray-900">
|
<div className="flex h-screen bg-gray-100 dark:bg-gray-900">
|
||||||
{/* Sidebar com barra de rolagem */}
|
{/* Sidebar com barra de rolagem */}
|
||||||
@@ -127,7 +134,11 @@ export const MainLayout: React.FC = () => {
|
|||||||
<nav className="flex-1 overflow-y-auto">
|
<nav className="flex-1 overflow-y-auto">
|
||||||
<div className="py-4">
|
<div className="py-4">
|
||||||
{menuItems.map((item, index) => (
|
{menuItems.map((item, index) => (
|
||||||
<div key={item.path || item.label} className="px-2 mb-2">
|
<div
|
||||||
|
key={item.path || item.label}
|
||||||
|
className="px-2 mb-2"
|
||||||
|
onMouseEnter={handleMenuHover}
|
||||||
|
>
|
||||||
{!item.subitems ? (
|
{!item.subitems ? (
|
||||||
<Link
|
<Link
|
||||||
to={item.path}
|
to={item.path}
|
||||||
@@ -155,15 +166,12 @@ export const MainLayout: React.FC = () => {
|
|||||||
<span className="text-xs mt-1 text-white/80">{item.label}</span>
|
<span className="text-xs mt-1 text-white/80">{item.label}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Submenu corrigido - posicionado fora da sidebar como pop-up */}
|
{/* Submenu como pop-up fora da estrutura do menu principal */}
|
||||||
<div
|
<div className="fixed left-20 z-50" style={{ top: 'var(--menu-item-top, 0)' }}>
|
||||||
className="fixed left-20 z-50"
|
<div
|
||||||
style={{
|
className="opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 ml-2"
|
||||||
top: 'var(--submenu-top)',
|
style={{ transformOrigin: 'left center' }}
|
||||||
'--submenu-top': `${index * 70 + 100}px`
|
>
|
||||||
} as React.CSSProperties}
|
|
||||||
>
|
|
||||||
<div className="opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200">
|
|
||||||
<div className="bg-blue-800/95 backdrop-blur-sm rounded-lg py-2 px-1 shadow-xl w-[140px] border border-blue-700/30">
|
<div className="bg-blue-800/95 backdrop-blur-sm rounded-lg py-2 px-1 shadow-xl w-[140px] border border-blue-700/30">
|
||||||
{item.subitems
|
{item.subitems
|
||||||
.filter(subitem =>
|
.filter(subitem =>
|
||||||
|
|||||||
Reference in new issue
Block a user