feat(FE:TraceGanttChart): scroll to selected row on page load (#213)

* feat(FE:TraceGanttChart): scroll to selected scroll on page load

* refactor: update handleScroll

* refactor(traceGanttChart): scroll on selected row
This commit is contained in:
NIDHI TANDON 2021-07-14 12:35:40 +05:30 committed by GitHub
parent 27e2ceffaa
commit beb15e0a5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,7 +57,7 @@ const TraceGanttChart = ({
}
setTabsContainerWidth(tabsContainer?.offsetWidth);
}
// handleScroll(selectedSpan?.id);
handleScroll(selectedSpan?.id);
}, [sortedTreeData, treeData, clickedSpan]);
useEffect(() => {
@ -229,7 +229,7 @@ const TraceGanttChart = ({
};
const handleResetFocus = () => {
let rows = document.querySelectorAll("#collapsable table tbody tr");
const rows = document.querySelectorAll("#collapsable table tbody tr");
Array.from(rows).map((row) => {
row.classList.remove("hide");
});
@ -237,16 +237,13 @@ const TraceGanttChart = ({
resetZoom(true);
};
const handleScroll = (id) => {
let rows = document.querySelectorAll("#collapsable table tbody tr");
const table = document.querySelectorAll("#collapsable table");
Array.from(rows).map((row) => {
let attribKey = row.getAttribute("data-row-key");
if (id === attribKey) {
let scrollValue = row.offsetTop;
table[1].scrollTop = scrollValue;
}
});
const handleScroll = (id: string): void => {
if (!isEmpty(id)) {
const selectedRow = document.querySelectorAll<HTMLElement>(
`[data-row-key='${id}']`,
);
selectedRow?.[0]?.scrollIntoView();
}
};
const rowSelection = {