mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
(clean) comments
This commit is contained in:
@@ -61,7 +61,6 @@ export default function ContextMenu({
|
||||
let top = rect.bottom + scrollY + offset.y;
|
||||
let left = rect.right + scrollX + offset.x;
|
||||
|
||||
// Adjust position based on position prop
|
||||
switch (position) {
|
||||
case 'bottom-left':
|
||||
left = rect.left + scrollX - offset.x;
|
||||
|
||||
@@ -13,7 +13,6 @@ type DropdownMenuProps = {
|
||||
className?: string;
|
||||
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
||||
offset?: { x: number; y: number };
|
||||
contextMenuAdjacent?: boolean; // New prop to indicate if it should position next to context menu
|
||||
};
|
||||
|
||||
export default function DropdownMenu({
|
||||
@@ -28,7 +27,6 @@ export default function DropdownMenu({
|
||||
className = '',
|
||||
position = 'bottom-right',
|
||||
offset = { x: 0, y: 8 },
|
||||
contextMenuAdjacent = false, // Default to false for backward compatibility
|
||||
}: DropdownMenuProps) {
|
||||
const dropdownRef = React.useRef<HTMLDivElement>(null);
|
||||
const [internalIsOpen, setInternalIsOpen] = React.useState(false);
|
||||
@@ -71,30 +69,8 @@ export default function DropdownMenu({
|
||||
|
||||
const rect = anchorRef.current.getBoundingClientRect();
|
||||
|
||||
// Default positioning
|
||||
let top = rect.bottom + offset.y;
|
||||
let left = rect.right + offset.x;
|
||||
|
||||
if (contextMenuAdjacent) {
|
||||
// Position to the left of the context menu
|
||||
left = rect.left - 50; // Width of dropdown + some spacing
|
||||
top = rect.top; // Align tops
|
||||
} else {
|
||||
// Standard positioning based on position prop
|
||||
switch (position) {
|
||||
case 'bottom-left':
|
||||
left = rect.left - offset.x;
|
||||
break;
|
||||
case 'top-right':
|
||||
top = rect.top - offset.y;
|
||||
break;
|
||||
case 'top-left':
|
||||
top = rect.top - offset.y;
|
||||
left = rect.left - offset.x;
|
||||
break;
|
||||
// bottom-right is default
|
||||
}
|
||||
}
|
||||
const top = rect.bottom + offset.y;
|
||||
const left = rect.right + offset.x;
|
||||
|
||||
return {
|
||||
position: 'fixed',
|
||||
|
||||
@@ -87,17 +87,13 @@ export default function Documents({
|
||||
activeMenuId === docId;
|
||||
|
||||
if (isAnyMenuOpen) {
|
||||
// Close both menus
|
||||
setSyncMenuState((prev) => ({ ...prev, isOpen: false, docId: null }));
|
||||
setActiveMenuId(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// If no menu is open, open the context menu
|
||||
setActiveMenuId(docId);
|
||||
};
|
||||
|
||||
// Close menu when clicking outside
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
if (activeMenuId) {
|
||||
|
||||
@@ -84,10 +84,8 @@ export default function General() {
|
||||
return (
|
||||
<div className="mt-12 flex flex-col gap-6">
|
||||
{' '}
|
||||
{/* Added consistent gap between sections */}
|
||||
<div className="flex flex-col gap-6">
|
||||
{' '}
|
||||
{/* Consistent gap between label and input */}
|
||||
<label className="font-bold text-jet dark:text-bright-gray">
|
||||
{t('settings.general.selectTheme')}
|
||||
</label>
|
||||
@@ -171,9 +169,7 @@ export default function General() {
|
||||
setPrompts={setPrompts}
|
||||
/>
|
||||
</div>
|
||||
{/* Add horizontal line before delete button */}
|
||||
<hr className="border-t border-silver dark:border-silver/40" />
|
||||
{/* Delete conversations button without label */}
|
||||
<div className="flex flex-col gap-2">
|
||||
<button
|
||||
className="flex w-56 cursor-pointer items-center justify-between rounded-3xl border border-solid border-rosso-corsa bg-transparent px-5 py-3 text-rosso-corsa transition-colors hover:bg-rosso-corsa hover:text-white dark:hover:text-white"
|
||||
|
||||
@@ -141,15 +141,12 @@ function LogsTable({ logs, setPage, loading }: LogsTableProps) {
|
||||
};
|
||||
|
||||
const firstObserver = useCallback((node: HTMLDivElement | null) => {
|
||||
// Cleanup previous observer
|
||||
if (observerRef.current) {
|
||||
observerRef.current.disconnect();
|
||||
}
|
||||
|
||||
// If node is null, just cleanup and return
|
||||
if (!node) return;
|
||||
|
||||
// Create new observer
|
||||
observerRef.current = new IntersectionObserver((entries) => {
|
||||
if (entries[0].isIntersecting) {
|
||||
setPage((prev) => prev + 1);
|
||||
@@ -159,7 +156,6 @@ function LogsTable({ logs, setPage, loading }: LogsTableProps) {
|
||||
observerRef.current.observe(node);
|
||||
}, []);
|
||||
|
||||
// Cleanup observer on component unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (observerRef.current) {
|
||||
|
||||
Reference in New Issue
Block a user