Make WordPress Core

09/08/2017 07:10:59 PM (7 years ago)

Widgets: Add dirty state tracking for widgets on admin screen.

  • Mark a widget as dirty when a field input triggers a change or input event; clear dirty state when widget is successfully saved.
  • Disable Save button and re-label "Saved" when widget not dirty.
  • Show AYS dialog when leaving widgets admin screen with unsaved changes.
  • When widgets are dirty, expand all unsaved widgets at AYS check and focus on first one.
  • Change "Close" link to "Done"; hide link when widget is dirty and reveal when saved.
  • The "Done" link persistently appears in the Customizer even after making a change (when the widget is dirty) because changes are autosaved into the changeset.
  • Prevent saving widget when form fails checkValidity.
  • Fix frequency of triggering of change event on the rich Text widget's textarea limited now to when there are actual changes.
  • Add a class of widget-dirty to widget containers when the widget has unsaved changes.

Props westonruter, timmydcrawford, melchoyce.
Fixes #41610, #23120.

1 edited


  • trunk/src/wp-admin/includes/widgets.php

    r40480 r41352  
    254254    <div class="widget-control-actions">
    255255        <div class="alignleft">
    256             <button type="button" class="button-link button-link-delete widget-control-remove"><?php _e( 'Delete' ); ?></button> |
    257             <button type="button" class="button-link widget-control-close"><?php _e( 'Close' ); ?></button>
     256            <button type="button" class="button-link button-link-delete widget-control-remove"><?php _e( 'Delete' ); ?></button>
     257            <span class="widget-control-close-wrapper">
     258                |
     259                <button type="button" class="button-link widget-control-close"><?php _e( 'Done' ); ?></button>
     260            </span>
    258261        </div>
    259262        <div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>">
Note: See TracChangeset for help on using the changeset viewer.