feat: khi người dùng click vào nút Chi tiết hành trình thì sẽ tự cuộn đến mốc thời gian hiện tại

This commit is contained in:
2026-06-24 21:25:04 +07:00
parent 5e60614588
commit f17215f236
9 changed files with 147 additions and 116 deletions
+12 -1
View File
@@ -207,6 +207,17 @@ export const ItineraryTimeline = ({
if (storedLegId) {
setExpandedStageId(storedLegId);
sessionStorage.removeItem('defaultExpandedLegId');
setTimeout(() => {
const targetElement = document.getElementById(`leg-anchor-node-${storedLegId}`);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
window.history.replaceState({}, document.title);
}, 150);
} else if (legs.length > 0 && !expandedStageId) {
setExpandedStageId(legs[0].id);
}
@@ -232,7 +243,7 @@ export const ItineraryTimeline = ({
const prevLegLastLoc = legIdx > 0 ? legs[legIdx - 1]?.locations.slice(-1)[0] : null;
return (
<section key={leg.id} className={`folder-node-wrapper ${expandedStageId === leg.id ? 'expanded' : 'collapsed'}`}>
<section key={leg.id} id={`leg-anchor-node-${leg.id}`} className={`folder-node-wrapper scroll-mt-[70px] ${expandedStageId === leg.id ? 'expanded' : 'collapsed'}`}>
{/* Folder header row - clickable to toggle exclusive expansion */}
<div
onClick={() => toggleStageExpanded(leg.id)}