fix(cashflow): use Turbo.visit for donut chart deep-link navigation (#2166)

Replaces window.location.href with Turbo.visit for SPA-consistent
navigation, matching the pattern used across internal navigation in
the codebase (selectable_link_controller, trade_form_controller, etc.).
This commit is contained in:
Will Wilson
2026-06-16 15:51:53 +01:00
committed by GitHub
parent ee89aec850
commit 7dbb548479

View File

@@ -1,5 +1,6 @@
import { Controller } from "@hotwired/stimulus";
import * as d3 from "d3";
import { buildCategoryTransactionsUrl } from "utils/transactions_filter_url";
// Connects to data-controller="donut-chart"
export default class extends Controller {
@@ -250,14 +251,15 @@ export default class extends Controller {
// Handles click on segment (optional, controlled by enableClick value)
#handleClick(segment) {
if (!segment.name || !this.startDateValue || !this.endDateValue) return;
if (!segment.name) return;
const segmentName = encodeURIComponent(segment.name);
const startDate = this.startDateValue;
const endDate = this.endDateValue;
const url = `/transactions?q[categories][]=${segmentName}&q[start_date]=${startDate}&q[end_date]=${endDate}`;
window.location.href = url;
Turbo.visit(
buildCategoryTransactionsUrl({
name: segment.name,
startDate: this.startDateValue,
endDate: this.endDateValue,
}),
);
}
// Public methods for external highlighting (e.g., from category list hover)