Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

fix table selection animations

Guy Ben-Aharon3f9a2f3a328c
diff --git a/src/components/select-box/select-box.tsx b/src/components/select-box/select-box.tsx
index a5e09d86..f88d9766 100644
--- a/src/components/select-box/select-box.tsx
+++ b/src/components/select-box/select-box.tsx
@@ -41,7 +41,6 @@ interface SelectBoxProps {
showClear?: boolean;
keepOrder?: boolean;
disabled?: boolean;
- onAnimationEnd?: React.AnimationEventHandler<HTMLDivElement>;
}
export const SelectBox = React.forwardRef<HTMLInputElement, SelectBoxProps>(
@@ -62,7 +61,6 @@ export const SelectBox = React.forwardRef<HTMLInputElement, SelectBoxProps>(
showClear,
keepOrder,
disabled,
- onAnimationEnd,
},
ref
) => {
@@ -212,7 +210,6 @@ export const SelectBox = React.forwardRef<HTMLInputElement, SelectBoxProps>(
<PopoverContent
className="w-fit min-w-[var(--radix-popover-trigger-width)] p-0"
align="center"
- onAnimationEnd={onAnimationEnd}
>
<Command
filter={(value, search) =>
diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-index/table-index.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-index/table-index.tsx
index 6a01b516..55204f0a 100644
--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-index/table-index.tsx
+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-index/table-index.tsx
@@ -42,7 +42,6 @@ export const TableIndex: React.FC<TableIndexProps> = ({
<SelectBox
className="flex h-8 min-h-8 min-w-0 flex-1"
multiple
- onAnimationEnd={(e) => e.stopPropagation()}
oneLine
options={fieldOptions}
placeholder={t(
diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx
index d7c266e6..e4dff95e 100644
--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx
+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx
@@ -1,4 +1,4 @@
-import React, { useCallback } from 'react';
+import React, { useCallback, useMemo } from 'react';
import { Accordion } from '@/components/accordion/accordion';
import { TableListItem } from './table-list-item/table-list-item';
import { DBTable } from '@/lib/domain/db-table';
@@ -10,12 +10,17 @@ export interface TableListProps {
export const TableList: React.FC<TableListProps> = ({ tables }) => {
const { openTableFromSidebar, openedTableInSidebar } = useLayout();
- const refs = tables.reduce(
- (acc, table) => {
- acc[table.id] = React.createRef();
- return acc;
- },
- {} as Record<string, React.RefObject<HTMLDivElement>>
+ const lastOpenedTable = React.useRef<string | null>(null);
+ const refs = useMemo(
+ () =>
+ tables.reduce(
+ (acc, table) => {
+ acc[table.id] = React.createRef();
+ return acc;
+ },
+ {} as Record<string, React.RefObject<HTMLDivElement>>
+ ),
+ [tables]
);
const scrollToTable = useCallback(
@@ -28,7 +33,11 @@ export const TableList: React.FC<TableListProps> = ({ tables }) => {
);
const handleScrollToTable = useCallback(() => {
- if (openedTableInSidebar) {
+ if (
+ openedTableInSidebar &&
+ lastOpenedTable.current !== openedTableInSidebar
+ ) {
+ lastOpenedTable.current = openedTableInSidebar;
scrollToTable(openedTableInSidebar);
}
}, [scrollToTable, openedTableInSidebar]);