Skip to content

Latest commit

 

History

History
151 lines (120 loc) · 5.31 KB

File metadata and controls

151 lines (120 loc) · 5.31 KB

Footer Widget Editor - UDC Integration Fixes

Issues Fixed

1. UDC Integration Not Working

Problem: The editor wasn't properly integrated with the Unified Data Context, so changes weren't being saved.

Solution:

  • Changed from onChange prop to onConfigChange prop (matching other special editors)
  • Removed the problematic useEffect that was trying to sync data
  • Added updateConfig callback that calls onConfigChange with the full widget configuration
  • All handler functions now call updateConfig to propagate changes through UDC

2. No Vertical Scrolling

Problem: The editor content wasn't scrollable when it exceeded viewport height.

Solution:

  • Restructured the component with proper flex layout:
    • Outer container: h-full flex flex-col overflow-hidden
    • Header section: flex-shrink-0 (fixed at top)
    • Content area: flex-1 overflow-y-auto (scrollable)

3. Save Button Not Appearing

Problem: Changes weren't being detected by the DataManager, so the save button never activated.

Solution:

  • Proper UDC integration via onConfigChange ensures all changes are tracked
  • Each user action (add/remove column, add/remove item, update values, drag-drop) now triggers updateConfig
  • DataManager receives updates through SpecialEditorRenderer's handleConfigChange

Technical Changes Made

File: frontend/src/widgets/easy-widgets/FooterWidgetEditor.jsx

Props Updated

// Before
const FooterWidgetEditor = ({ config = {}, onChange }) => {

// After
const FooterWidgetEditor = ({
    widgetData,
    isAnimating = false,
    isClosing = false,
    onConfigChange
}) => {

Config Management

// Extract config from widgetData
const config = widgetData?.config || {}

// Sync local state when external config changes
useEffect(() => {
    setColumns(config.columns || [])
    setColumnCount(config.columnCount || 3)
}, [config.columns, config.columnCount])

// Update helper that calls onConfigChange
const updateConfig = useCallback((newColumns, newColumnCount) => {
    if (onConfigChange) {
        onConfigChange({
            ...config,
            columns: newColumns,
            columnCount: newColumnCount
        })
    }
}, [config, onConfigChange])

All Handlers Updated

All modification functions now call updateConfig:

  • addColumn() - calls updateConfig(newColumns, newColumnCount)
  • removeColumn() - calls updateConfig(newColumns, newColumnCount)
  • updateColumnTitle() - calls updateConfig(newColumns, columnCount)
  • addItem() - calls updateConfig(newColumns, columnCount)
  • removeItem() - calls updateConfig(newColumns, columnCount)
  • updateItem() - calls updateConfig(newColumns, columnCount)
  • handleDrop() - calls updateConfig(newColumns, columnCount) after drag-drop

Layout Structure

<div className="h-full flex flex-col overflow-hidden">
    {/* Fixed Header */}
    <div className="flex-shrink-0 p-4 border-b border-gray-200 bg-white">
        <h2>Footer Configuration</h2>
    </div>
    
    {/* Scrollable Content */}
    <div className="flex-1 overflow-y-auto p-4 space-y-6">
        {/* All editor content here */}
    </div>
</div>

How It Works Now

Data Flow

  1. User makes a change → Handler function called (e.g., addItem())
  2. Handler updates local statesetColumns(newColumns)
  3. Handler calls updateConfig() → Passes new data to parent
  4. updateConfig() calls onConfigChange() → Special editor prop
  5. SpecialEditorRenderer receives changehandleConfigChange() called
  6. SpecialEditorRenderer publishes to UDCpublishUpdate() with UPDATE_WIDGET_CONFIG
  7. DataManager detects change → Save button appears
  8. User clicks save → Data persists to backend

Integration with Special Editor System

The FooterWidgetEditor now follows the same pattern as MediaSpecialEditor and TableSpecialEditor:

  • Receives widgetData with current config
  • Uses onConfigChange callback to report changes
  • Maintains local state for immediate UI updates
  • Syncs with external changes via useEffect
  • Lets SpecialEditorRenderer handle all UDC operations

Testing Checklist

  • Vertical scrolling works when content exceeds viewport
  • Add/remove columns triggers save button
  • Add/remove items triggers save button
  • Editing column title triggers save button
  • Editing item label triggers save button
  • Editing item URL triggers save button
  • Toggle "open in new tab" triggers save button
  • Drag-drop reordering triggers save button
  • Save button actually saves changes to backend
  • Changes persist after page reload
  • No linter errors

Files Modified

  1. frontend/src/widgets/easy-widgets/FooterWidgetEditor.jsx
    • Complete refactor for UDC integration
    • Added scrollable container
    • All handlers now call updateConfig

Related Files (No changes needed)

  • frontend/src/components/special-editors/SpecialEditorRenderer.jsx - Already had FooterWidgetEditor registered
  • frontend/src/widgets/easy-widgets/eceeeFooterWidget.jsx - Already had specialEditor: 'FooterWidgetEditor' in metadata

Next Steps

  1. Test the editor in the page editor
  2. Verify all changes save correctly
  3. Test with existing footer widgets (backward compatibility)
  4. Test responsive behavior of rendered footer