@@ -2,9 +2,10 @@ import { useState, useCallback, memo } from 'react';
22import {
33 serializeFiltersToURL ,
44 getFullURLWithFiltersState ,
5+ getFullURLWithComparisonState ,
56 generateSectionId ,
67} from '../utils/url-utils' ;
7- import { useFilters } from '../contexts/FilterContext' ;
8+ import { useFilters , useComparison } from '../contexts/FilterContext' ;
89import Tooltip from './Tooltip' ;
910import { getTooltipPosition } from '../utils/tooltip-utils' ;
1011
@@ -24,6 +25,8 @@ const ChartHeader = ({ title, compact = false, className }) => {
2425
2526 // Get filters from context - this is the source of truth
2627 const filters = useFilters ( ) ;
28+ // Get comparison state from context
29+ const { comparisonMode, filtersA, filtersB } = useComparison ( ) ;
2730 const sectionId = generateSectionId ( title ) ;
2831
2932 const handleAnchorClick = useCallback ( ( e ) => {
@@ -32,19 +35,30 @@ const ChartHeader = ({ title, compact = false, className }) => {
3235
3336 if ( ! sectionId ) return ;
3437
38+ let newHash , fullUrl ;
39+
40+ if ( comparisonMode ) {
41+ // Comparison mode - include both filter sets
42+ const comparisonState = { comparisonMode : true , filtersA, filtersB } ;
43+ newHash = serializeFiltersToURL ( null , sectionId , comparisonState ) ;
44+ fullUrl = getFullURLWithComparisonState ( comparisonState , sectionId ) ;
45+ } else {
46+ // Normal mode
47+ newHash = serializeFiltersToURL ( filters , sectionId ) ;
48+ fullUrl = getFullURLWithFiltersState ( filters , sectionId ) ;
49+ }
50+
3551 // Build hash from React state (source of truth, not potentially stale URL)
36- const newHash = serializeFiltersToURL ( filters , sectionId ) ;
3752 window . history . pushState ( null , '' , newHash ) ;
3853
3954 // Copy full URL with current filters from React state
40- const fullUrl = getFullURLWithFiltersState ( filters , sectionId ) ;
4155 navigator . clipboard . writeText ( fullUrl ) . then ( ( ) => {
4256 setCopied ( true ) ;
4357 setTimeout ( ( ) => setCopied ( false ) , 1500 ) ;
4458 } ) . catch ( ( ) => {
4559 // Fallback: just update the hash without clipboard notification
4660 } ) ;
47- } , [ sectionId , filters ] ) ;
61+ } , [ sectionId , filters , comparisonMode , filtersA , filtersB ] ) ;
4862
4963 const handleMouseEnter = useCallback ( ( e ) => {
5064 if ( ! copied ) {
0 commit comments