Skip to content

Commit

Permalink
Scrolls child cases into view on keyboard selection
Browse files Browse the repository at this point in the history
  • Loading branch information
eireland committed Dec 24, 2024
1 parent 73e9dd7 commit ca24779
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions v3/src/components/case-table/collection-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,30 @@ export const CollectionTable = observer(function CollectionTable(props: IProps)
selectCases([nextCaseId], data)
}
} else {
let caseIds = [nextCaseId]
setSelectedCases([nextCaseId], data)
// loop through collections and scroll newly selected child cases into view
const collection = data?.getCollection(collectionId)
for (let childCollection = collection?.child; childCollection; childCollection = childCollection?.child) {
const childCaseIds: string[] = []
const childIndices: number[] = []
caseIds.forEach(id => {
const caseInfo = data?.caseInfoMap.get(id)
caseInfo?.childCaseIds?.forEach(childCaseId => {
childCaseIds.push(childCaseId)
const caseIndex = collectionCaseIndexFromId(childCaseId, data, childCollection.id)
if (caseIndex != null) {
childIndices.push(caseIndex)
}
})
})
// scroll to newly selected child cases (if any)
if (childIndices.length) {
onScrollRowRangeIntoView(childCollection.id, childIndices, { disableScrollSync: true })
}
// advance to child cases in next collection
caseIds = childCaseIds
}
}
}
}
Expand Down

0 comments on commit ca24779

Please sign in to comment.