Skip to content

Redraw chart when its modal or accordion pane is shown - #3134

Closed
wakqasahmed wants to merge 2 commits into
orchidsoftware:masterfrom
wakqasahmed:fix/chart-modal-accordion-render-3089
Closed

Redraw chart when its modal or accordion pane is shown#3134
wakqasahmed wants to merge 2 commits into
orchidsoftware:masterfrom
wakqasahmed:fix/chart-modal-accordion-render-3089

Conversation

@wakqasahmed

Copy link
Copy Markdown
Contributor

The chart is constructed at new Chart(this.data.get("parent"), ...) in connect(), which sizes itself off the container's width at that moment. Inside a modal or an accordion pane that's still display:none, that's zero — the SVG comes out with width="0" and garbage path coordinates. The existing shown.bs.tab listener already redraws it for the tab case, but nothing covers a modal or a collapse, matching what's reported: only the chart that happens to be visible on load renders correctly.

Same fix as the tab one: find the closest .modal / .collapse ancestor and redraw on shown.bs.modal / shown.bs.collapse.

Reproduced this outside the app with the actual frappe-charts build and a real Bootstrap 5 modal/collapse — confirmed a chart built while hidden renders with width="0" and negative/garbage path coordinates, and that firing the same redraw this PR adds fixes both cases (width comes back correct and the path matches a chart built while visible). No JS test harness exists in this repo for Stimulus controllers (same as #3130), so that browser check is what I verified against instead of an automated test.

Fixes #3089

wakqasahmed and others added 2 commits September 4, 2026 22:06
The chart is built at construction time via new Chart(this.data.get("parent"), ...),
which sizes itself from the container's current width. Inside a modal or accordion
pane that's still display:none at that point, it gets built at zero width, and the
existing shown.bs.tab listener never covers this case since neither container is a
tab.

Wires shown.bs.modal / shown.bs.collapse on the closest .modal / .collapse ancestor,
same pattern as the tab listener, calling the existing debounced draw().

Fixes orchidsoftware#3089
@wakqasahmed

Copy link
Copy Markdown
Contributor Author

Closing in favor of #3135 — this PR had the wrong commit author (a stray local git config override, not you).

@wakqasahmed wakqasahmed closed this Sep 4, 2026
@wakqasahmed
wakqasahmed deleted the fix/chart-modal-accordion-render-3089 branch September 4, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Multiple Charts brake in modals or accordions.

1 participant