@@ -37,8 +37,12 @@ interface MetricsGraphSectionProps {
3737 selectQuery : ( query : QuerySelection ) => void ;
3838 setProfileSelection : ( mergeFrom : bigint , mergeTo : bigint , query : Query ) => void ;
3939 query : Query ;
40- setNewQueryExpression : ( queryExpression : string , commit ?: boolean ) => void ;
40+ setNewQueryExpression : ( queryExpression : string ) => void ;
4141 setQueryExpression : ( updateTs ?: boolean ) => void ;
42+ commitDraft : (
43+ refreshedTimeRange ?: { from : number ; to : number ; timeSelection : string } ,
44+ expression ?: string
45+ ) => void ;
4246}
4347
4448export function MetricsGraphSection ( {
@@ -57,6 +61,7 @@ export function MetricsGraphSection({
5761 setProfileSelection,
5862 query,
5963 setNewQueryExpression,
64+ commitDraft,
6065} : MetricsGraphSectionProps ) : JSX . Element {
6166 const resetStateOnSeriesChange = useResetStateOnSeriesChange ( ) ;
6267 const batchUpdates = useURLStateBatch ( ) ;
@@ -106,9 +111,11 @@ export function MetricsGraphSection({
106111 }
107112
108113 if ( hasChanged ) {
109- // TODO: Change this to store the query object
110- // Pass commit: true to immediately apply the filter when clicking on metrics graph labels
111- setNewQueryExpression ( newQuery . toString ( ) , true ) ;
114+ // Immediately apply the filter when adding label matchers from the graph
115+ batchUpdates ( ( ) => {
116+ setNewQueryExpression ( newQuery . toString ( ) ) ;
117+ commitDraft ( undefined , newQuery . toString ( ) ) ;
118+ } ) ;
112119 }
113120 } ;
114121
0 commit comments