+ if (!isOpen) return null;
+
+ const getMenuPosition = (): React.CSSProperties => {
+ if (!anchorRef?.current) return {};
+
+ 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
+ }
+ }
+
+ return {
+ position: 'fixed',
+ top: `${top}px`,
+ left: `${left}px`,
+ zIndex: 9999,
+ };
+ };
+
+ // Use a portal to render the dropdown outside the table flow
+ return ReactDOM.createPortal(
+
e.stopPropagation()}
+ >
+
,
+ document.body,
);
}
diff --git a/frontend/src/settings/Documents.tsx b/frontend/src/settings/Documents.tsx
index b1b04006..61cf063d 100644
--- a/frontend/src/settings/Documents.tsx
+++ b/frontend/src/settings/Documents.tsx
@@ -6,6 +6,7 @@ import userService from '../api/services/userService';
import ArrowLeft from '../assets/arrow-left.svg';
import caretSort from '../assets/caret-sort.svg';
import Edit from '../assets/edit.svg';
+import EyeView from '../assets/eye-view.svg';
import NoFilesDarkIcon from '../assets/no-files-dark.svg';
import NoFilesIcon from '../assets/no-files.svg';
import SyncIcon from '../assets/sync.svg';
@@ -81,13 +82,19 @@ export default function Documents({
e.preventDefault();
e.stopPropagation();
- // Close any open menu if clicking on a different button
- if (activeMenuId && activeMenuId !== docId) {
+ const isAnyMenuOpen =
+ (syncMenuState.isOpen && syncMenuState.docId === docId) ||
+ activeMenuId === docId;
+
+ if (isAnyMenuOpen) {
+ // Close both menus
+ setSyncMenuState((prev) => ({ ...prev, isOpen: false, docId: null }));
setActiveMenuId(null);
+ return;
}
- // Toggle the clicked menu
- setActiveMenuId((prev) => (prev === docId ? null : docId));
+ // If no menu is open, open the context menu
+ setActiveMenuId(docId);
};
// Close menu when clicking outside
@@ -223,6 +230,16 @@ export default function Documents({
const getActionOptions = (index: number, document: Doc): MenuOption[] => {
const actions: MenuOption[] = [
+ {
+ icon: EyeView,
+ label: t('settings.documents.view'),
+ onClick: () => {
+ setShowDocumentChunks(document);
+ },
+ iconWidth: 18,
+ iconHeight: 18,
+ variant: 'primary',
+ },
{
icon: Trash,
label: t('convTile.delete'),
@@ -312,8 +329,8 @@ export default function Documents({
{t('settings.documents.name')}
|
-
-
+
+
{t('settings.documents.date')}
|
-
-
+
+
{t('settings.documents.tokenUsage')}
@@ -339,10 +356,8 @@ export default function Documents({
/>
|
-
-
- {t('settings.documents.actions')}
-
+ |
+ {t('settings.documents.actions')}
|
@@ -363,27 +378,23 @@ export default function Documents({
const docId = document.id ? document.id.toString() : '';
return (
- setShowDocumentChunks(document)}
- >
+
|
{document.name}
|
-
+ |
{document.date ? formatDate(document.date) : ''}
|
-
+ |
{document.tokens
? formatTokens(+document.tokens)
: ''}
|
e.stopPropagation()}
>
)}
| | |