[loggi-qmb] Fix: drag-and-drop reorder in Customize modal duplicates charts #118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bead ID:
loggi-qmbType: bug
Priority: P1
Status: closed
Close reason: Fixed two bugs: (1) Changed onEnd selector from querySelectorAll('[data-plot-id]') to querySelectorAll(':scope > [data-plot-id]') so it only matches wrapper divs, not nested inputs. (2) Added deduplication in getOrderedPlotIds() using a Set to gracefully handle previously corrupted saved orders.
Why
Dragging to reorder charts in the Customize modal causes every chart to appear twice in the stats grid.
Root cause
In
openPlotCustomize(), theonEndSortableJS handler uses:This selector matches both the wrapper
<div data-plot-id="...">and the nested<input data-plot-id="...">inside each list item, so the saved order array contains every plot ID twice. WhenrenderStatsGriditerates over this doubled array, it builds each chart card twice.What
Change the selector in the
onEndhandler to only match direct children of the list (the wrapper divs), not the nested inputs. Use:scope > [data-plot-id]orlist.children.Verify that
getOrderedPlotIds()also deduplicates gracefully (it currently doesn't —filterpreserves duplicates).Acceptance criteria
Where
app/static/js/stats.js—onEndhandler (~L300),getOrderedPlotIds()(~L115)