Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jul 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 9 additions & 12 deletions frontend/src/modules/Traces/TraceGanttChart/TraceGanttChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const TraceGanttChart = ({
}
setTabsContainerWidth(tabsContainer?.offsetWidth);
}
// handleScroll(selectedSpan?.id);
handleScroll(selectedSpan?.id);
}, [sortedTreeData, treeData, clickedSpan]);

useEffect(() => {
Expand Down Expand Up @@ -229,24 +229,21 @@ 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");
});

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 = {
Expand Down