click overlap event issue

This commit is contained in:
AI Christianson 2025-03-14 16:27:10 -04:00
parent fe3adbd241
commit 7d85dc2b05
1 changed files with 33 additions and 15 deletions

View File

@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { createPortal } from 'react-dom';
import { PanelLeft } from 'lucide-react'; import { PanelLeft } from 'lucide-react';
import { import {
Button, Button,
@ -183,12 +184,21 @@ export const DefaultAgentScreen: React.FC = () => {
) )
); );
// Create floating action button for mobile sidebar toggle // Floating action button component that uses Portal to render at document body level
const floatingAction = ( const FloatingActionButton = ({ onClick }: { onClick: () => void }) => {
// Only render the portal on the client side, not during SSR
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
return () => setMounted(false);
}, []);
const button = (
<Button <Button
variant="default" variant="default"
size="icon" size="icon"
onClick={() => setIsDrawerOpen(true)} onClick={onClick}
aria-label="Toggle sessions panel" aria-label="Toggle sessions panel"
className="h-14 w-14 rounded-full shadow-xl bg-zinc-800 hover:bg-zinc-700 text-zinc-100 flex items-center justify-center border-2 border-zinc-700 dark:border-zinc-600" className="h-14 w-14 rounded-full shadow-xl bg-zinc-800 hover:bg-zinc-700 text-zinc-100 flex items-center justify-center border-2 border-zinc-700 dark:border-zinc-600"
> >
@ -196,6 +206,16 @@ export const DefaultAgentScreen: React.FC = () => {
</Button> </Button>
); );
const container = (
<div className="fixed bottom-6 right-6 z-[9999] md:hidden" style={{ pointerEvents: 'auto' }}>
{button}
</div>
);
// Return null during SSR, or the portal on the client
return mounted ? createPortal(container, document.body) : null;
};
return ( return (
<> <>
<Layout <Layout
@ -205,9 +225,7 @@ export const DefaultAgentScreen: React.FC = () => {
> >
{mainContent} {mainContent}
</Layout> </Layout>
<div className="fixed bottom-6 right-6 z-50 md:hidden" style={{zIndex: 9999}}> <FloatingActionButton onClick={() => setIsDrawerOpen(true)} />
{floatingAction}
</div>
</> </>
); );
}; };