Skip to content

Commit

Permalink
chore: eliminate no-longer-necessary case table scroll kludge (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson authored Jul 18, 2024
1 parent a0d047c commit 0f9b86d
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions v3/src/components/case-table/collection-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { useCollectionContext } from "../../hooks/use-collection-context"
import { useDataSetContext } from "../../hooks/use-data-set-context"
import { useTileDroppable } from "../../hooks/use-drag-drop"
import { useForceUpdate } from "../../hooks/use-force-update"
import { useTileModelContext } from "../../hooks/use-tile-model-context"
import { useVisibleAttributes } from "../../hooks/use-visible-attributes"
import { IDataSet } from "../../models/data/data-set"
import { useCaseTableModel } from "./use-case-table-model"
Expand Down Expand Up @@ -52,8 +51,6 @@ export const CollectionTable = observer(function CollectionTable(props: IProps)
const gridRef = useRef<DataGridHandle>(null)
const visibleAttributes = useVisibleAttributes(collectionId)
const { selectedRows, setSelectedRows, handleCellClick } = useSelectedRows({ gridRef, onScrollClosestRowIntoView })
const { isTileSelected } = useTileModelContext()
const isFocused = isTileSelected()
const forceUpdate = useForceUpdate()

useEffect(function setGridElement() {
Expand All @@ -64,15 +61,6 @@ export const CollectionTable = observer(function CollectionTable(props: IProps)
}
}, [collectionId, collectionTableModel, gridRef.current?.element, onMount])

useEffect(function syncScrollTop() {
// There is a bug, seemingly in React, in which the scrollTop property gets reset
// to 0 when the order of tiles is changed (which happens on selecting/focusing tiles
// in the free tile layout), even though the CollectionTable and the RDG grid component
// are not re-rendered or unmounted/mounted. Therefore, we reset the scrollTop property
// from our saved cache on focus change.
isFocused && collectionTableModel?.syncScrollTopToElement()
}, [collectionTableModel, isFocused])

// columns
const indexColumn = useIndexColumn()
const columns = useColumns({ data, indexColumn })
Expand Down

0 comments on commit 0f9b86d

Please sign in to comment.