From ff5a32747005214691190077e60c7024b06c5d86 Mon Sep 17 00:00:00 2001 From: Adam Mertel <12932677+adammertel@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:17:07 +0100 Subject: [PATCH] Statement list virtualized (#2435) * Create row is visible hook * Integrate hook into statement list row, fix some stylings * Refactor entity tag * Isolate expand button on row to prevent column reload on row select * Improve hidden table styles * theme loader * Fix row dragging * shorter context menu timeout on mouse leave --------- Co-authored-by: Petr Hanak --- packages/client/src/Theme/constants.ts | 2 +- .../advanced/EntityTag/EntityTag.tsx | 21 +- .../client/src/components/basic/Tag/Tag.tsx | 249 +++++++----------- .../src/components/basic/Tag/useDragDrop.tsx | 94 +++++++ .../StatementsListBox/StatementListBox.tsx | 4 +- .../StatementListContextMenu.tsx | 11 +- .../StatementListTable/StatementListRow.tsx | 106 ++++++-- .../StatementListTable/StatementListTable.tsx | 153 +++++------ .../StatementListTableStyles.tsx | 8 +- .../StatementListTable/useRowIsVisible.tsx | 26 ++ .../StatementLitBoxStyles.tsx | 7 +- 11 files changed, 390 insertions(+), 291 deletions(-) create mode 100644 packages/client/src/components/basic/Tag/useDragDrop.tsx create mode 100644 packages/client/src/pages/Main/containers/StatementsListBox/StatementListTable/useRowIsVisible.tsx diff --git a/packages/client/src/Theme/constants.ts b/packages/client/src/Theme/constants.ts index fd371a8d3..936067fb8 100644 --- a/packages/client/src/Theme/constants.ts +++ b/packages/client/src/Theme/constants.ts @@ -32,7 +32,7 @@ export const fourthPanelBoxesHeightThirds = { // the minimum pixels for the results section height export const MIN_SEARCH_RESULT_HEIGHT = 100; -export const COLLAPSED_TABLE_WIDTH = 90; +export const COLLAPSED_TABLE_WIDTH = 80; // LIMITS export const maxTabCount = 10; diff --git a/packages/client/src/components/advanced/EntityTag/EntityTag.tsx b/packages/client/src/components/advanced/EntityTag/EntityTag.tsx index f83f9299a..dbcc7b4ff 100644 --- a/packages/client/src/components/advanced/EntityTag/EntityTag.tsx +++ b/packages/client/src/components/advanced/EntityTag/EntityTag.tsx @@ -4,7 +4,7 @@ import { IEntity } from "@shared/types"; import { ThemeColor } from "Theme/theme"; import { Button, Tag } from "components"; import { EntityTooltip } from "components/advanced"; -import React, { ReactNode, useCallback, useState } from "react"; +import React, { ReactNode, useCallback, useRef, useState } from "react"; import { FaUnlink } from "react-icons/fa"; import { useAppSelector } from "redux/hooks"; import { DraggedEntityReduxItem, EntityDragItem } from "types"; @@ -78,21 +78,14 @@ export const EntityTag: React.FC = ({ } const classId = entity.class; + const [buttonHovered, setButtonHovered] = useState(false); const [elvlHovered, setElvlHovered] = useState(false); - - const [referenceElement, setReferenceElement] = - useState(null); const [tagHovered, setTagHovered] = useState(false); - const handleSetReferenceElement = useCallback( - (node: HTMLDivElement | null) => { - setReferenceElement(node); - }, - [] - ); + const referenceEl = useRef(null); - const renderUnlinkButton = useCallback((unlinkButton: UnlinkButton) => { + const renderUnlinkButton = (unlinkButton: UnlinkButton) => { return (