Overview
The Field Palette is a smart sidebar that automatically detects all available fields from your selected HubSpot form and makes them available for drag-and-drop. It intelligently shows only fields that aren’t already in use, preventing duplicates and maintaining a clean workspace.The Field Palette is implemented in
main/frontend/src/components/Sidebar.tsx (lines 152-168) and integrates with the drag-and-drop system through @dnd-kit/core.How It Works
Auto-Detection
When you select a HubSpot form, the palette automatically:- Fetches all fields from the form schema
- Filters out fields already in use on the canvas
- Displays only available fields
- Updates in real-time as you add/remove fields
Field Display
Field Item Structure
Each field in the palette displays:- Field label: The user-facing name from HubSpot
- Required badge: Visual indicator for required fields
- Drag handle: Visual cue (cursor changes to grab)
Required vs Optional Fields
Required Fields
- Cannot be deleted from canvas
- Display “Required” badge in palette
- Automatically added to first step on form selection
Optional Fields
- Can be added/removed freely
- No badge in palette
- Return to palette when deleted from canvas
Empty State
When all fields are in use:Dragging from Palette
Starting a Drag
Palette Field ID Format
Fields dragged from the palette have a special ID format to distinguish them from fields already on the canvas:Drop Zones
When dragging from the palette, you can drop fields in multiple locations:- Top of Row
- Center of Row
- Bottom of Row
- Empty Step
Drop in the top 20% of an existing row to create a new row above it.
Drop Zone Detection
The system uses precise collision detection:Field Validation
The palette includes built-in validation to prevent common errors:Duplicate Prevention
If you try to add a field that’s already on the canvas, the action is silently rejected and the field stays in the palette.
Row Capacity Check
Required Field Protection
Required fields:- Cannot be deleted from the canvas
- Don’t appear in the palette after initial placement
- Always remain on the form
Visual Feedback
During Drag
Field Being Dragged
Field Being Dragged
Drag Overlay
Drag Overlay
A ghost image of the field follows your cursor, showing the field label and any badges.
Drop Zone Highlight
Drop Zone Highlight
Valid drop zones are highlighted with borders as you hover over them.
Invalid Drop
Invalid Drop
No highlight appears if dropping in an invalid location (like a full row).
After Drop
Palette Workflow
Scenario 1: Adding a Previously Removed Field
Scenario 2: Building Layout from Scratch
Technical Integration
Component Location
Store Actions
The palette uses these Zustand store actions:These actions are defined in
main/hooks/useLayoutStore.ts and include validation logic documented in PALETTE_FEATURE_GUIDE.md (lines 53-75).Data Flow
Best Practices
Start with Required
Add all required fields first, then enhance with optional fields for better UX
Group Related Fields
Drag related fields (like name fields) to the same row for visual grouping
Test on Mobile
Rows with 3 fields may be tight on mobile - preview before finalizing
Use Empty Palette
Aim to use all available fields - empty palette means complete form
Troubleshooting
Palette Always Empty
Palette Always Empty
Problem: No fields appear in “Campos detectados”Solutions:
- Verify form schema loaded (check for error messages)
- Check if all fields are already on canvas
- Ensure layout is initialized (useLayoutStore.layout !== null)
Can't Drop Field
Can't Drop Field
Problem: Field won’t drop on canvasSolutions:
- Ensure you’re dropping in a valid zone (not a full row)
- Check that DndContext wraps both Sidebar and LayoutBuilder
- Verify field isn’t already on canvas (duplicate check)
Field Appears in Both Palette and Canvas
Field Appears in Both Palette and Canvas
Problem: Same field shown in two placesSolutions:
- This should never happen - indicates a bug
- Check collectFieldNames() function in useLayoutStore
- Verify usedFields Set is calculating correctly
Drag Doesn't Start
Drag Doesn't Start
Problem: Click doesn’t initiate dragSolutions:
- Verify DetectedFieldItem uses useDraggable hook
- Check that id and data props are set correctly
- Ensure DndContext includes Sidebar component
Related Documentation
- Visual Editor - Learn about the canvas and drop zones
- Preview Panel - See how fields render in the final form
- Module Export - Export your field layout to HubSpot
