From fb75b91c05420b086069b066582f2b8b4a1e3eb3 Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Wed, 11 Nov 2026 19:50:11 +0530 Subject: [PATCH 1/2] Add a locate button to the table list that centers the table on the canvas Finding a table in a large diagram meant panning around by hand, even though the side panel already lists every table. Each row in the tables tab now has a map pin button that selects the table, so it gets the usual blue selection border, and pans the canvas so the table sits in the middle of the view. The current zoom is kept. The button is disabled for hidden tables, since they are not drawn on the canvas. The pan target comes from a new getTableCenter helper that uses the same width and height calculations as the canvas. Rows are memoized, so the handler reads setTransform from a new TransformActionsContext (same pattern as the select, diagram and undo contexts) rather than the transform context. That way panning does not re-render every row. Closes #1198 Closes #1190 Signed-off-by: Asish Kumar --- .../EditorSidePanel/TablesTab/TablesTab.jsx | 27 ++++++++++++++++++- src/context/TransformContext.jsx | 13 ++++++--- src/i18n/locales/en.js | 1 + src/utils/utils.js | 12 +++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/components/EditorSidePanel/TablesTab/TablesTab.jsx b/src/components/EditorSidePanel/TablesTab/TablesTab.jsx index a11225970..c7ac8f362 100644 --- a/src/components/EditorSidePanel/TablesTab/TablesTab.jsx +++ b/src/components/EditorSidePanel/TablesTab/TablesTab.jsx @@ -1,6 +1,6 @@ import { memo, useContext } from "react"; import { Collapse, Button } from "@douyinfe/semi-ui"; -import { IconEyeOpened, IconEyeClosed } from "@douyinfe/semi-icons"; +import { IconEyeOpened, IconEyeClosed, IconMapPin } from "@douyinfe/semi-icons"; import { IconPlus } from "@douyinfe/semi-icons"; import { useSelect, @@ -10,9 +10,12 @@ import { useSettings, } from "../../../hooks"; import { DiagramActionsContext } from "../../../context/DiagramContext"; +import { TransformActionsContext } from "../../../context/TransformContext"; +import { SelectActionsContext } from "../../../context/SelectContext"; import { UndoRedoActionsContext } from "../../../context/UndoRedoContext"; import { Action, ObjectType, State } from "../../../data/constants"; import { useTranslation } from "react-i18next"; +import { getTableCenter } from "../../../utils/utils"; import { DragHandle } from "../../SortableList/DragHandle"; import { SortableList } from "../../SortableList/SortableList"; import SearchBar from "./SearchBar"; @@ -81,9 +84,22 @@ const TableListItem = memo(function TableListItem({ table }) { const { layout } = useLayout(); const { updateTable } = useContext(DiagramActionsContext); const { setUndoStack, setRedoStack } = useContext(UndoRedoActionsContext); + const { setTransform } = useContext(TransformActionsContext); + const { setSelectedElement } = useContext(SelectActionsContext); const { settings } = useSettings(); const { t } = useTranslation(); + const locateTable = (e) => { + e.stopPropagation(); + setSelectedElement((prev) => ({ + ...prev, + element: ObjectType.TABLE, + id: table.id, + open: false, + })); + setTransform({ pan: getTableCenter(table, settings.showComments) }); + }; + const toggleTableVisibility = (e) => { e.stopPropagation(); setUndoStack((prev) => [ @@ -125,6 +141,15 @@ const TableListItem = memo(function TableListItem({ table }) { )} +