Start the development server:
npm run dev
Open the browser console (F12) to see debug logs
Select a grid template:
Add a widget:
Test snapping:
Watch the console for debug output like:
[Snap Debug] Finding target: { widgetRect, widgetCenter, cellsCount, threshold }
[Snap Debug] Checking cell: { cellId, distance, withinThreshold }
[Snap Debug] Best cell: "cell-1"
Look for visual feedback:
Release the widget:
[Snap Debug] Finding target: { cellsCount: 4, threshold: 30 }
[Snap Debug] Checking cell: { cellId: "cell-1", distance: 15.2, withinThreshold: true }
[Snap Debug] Cell is candidate: { cellId: "cell-1", overlap: 0.45, score: -7.3 }
[Snap Debug] Best cell: "cell-1"
[Snap Debug] Drag: { snapped: true, targetCellId: "cell-1" }
[Snap Debug] Finding target: { cellsCount: 4, threshold: 30 }
[Snap Debug] Checking cell: { cellId: "cell-1", distance: 450.8, withinThreshold: false }
[Snap Debug] Best cell: none
[Snap Debug] Drag: { snapped: false, targetCellId: null }
Symptom: Console shows distance: 450.8, withinThreshold: false
Cause: Coordinate space mismatch - widget and cells are in different coordinate systems
Solution: Check that:
Symptom: Console shows cellsCount: 0
Cause: Grid cells not being passed to WidgetRenderer
Solution: Verify grid template is selected and cells are defined
Symptom: All cells show withinThreshold: false
Cause: Threshold too small OR coordinates are scaled incorrectly
Solution:
SNAP_CONFIGscreenToGrid()Open browser console and run:
// Check grid configuration
JSON.parse(localStorage.getItem('dashboard-grid-config'))
// Check widget positions
JSON.parse(localStorage.getItem('dashboard-config'))
// Clear saved data and start fresh
localStorage.clear()
location.reload()
| Action | Expected Result |
|---|---|
| Drag widget near cell (< 30px) | Cell highlights with blue glow |
| Drag widget over cell center | Cell shows "Drop to snap" indicator |
| Release widget over cell | Widget snaps to cell position and size |
| Drag widget far from cells | No highlighting, free placement |
| Drag while no grid selected | No snapping, free placement |
Based on console output, we can diagnose:
Please run the test and share the console output!