Skip to content

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

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

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

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.

(Replaces #3134, which had the wrong commit author — closing that one.)

Fixes #3089

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
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