Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #23120, comment 46


Ignore:
Timestamp:
01/09/2017 07:01:53 AM (8 years ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #23120, comment 46

    initial v1  
    1 I just came across this issue when integrating [JS Widgets](https://github.com/xwp/wp-js-widgets) into the widgets admin screen. The direction I took was analogous to what is done in the customizer (surprise), where if the widget is not saved yet then the button says “Save” as it does currently, but once the widget has been updated (and the `widget-updated` event triggers) then the button becomes `disabled` and the text changes to “Saved”. Upon making another change to the widget, then the button becomes enabled again and the text returns to “Save”. In the case of an HTTP error, then the enabled Save button just will never turn to Saved. If the `WP_JS_Widget` failed a validation constraint, then the button would remain “Save” but a validation notification would appear in the control.
     1I just came across this issue when integrating [https://github.com/xwp/wp-js-widgets JS Widgets] into the widgets admin screen. The direction I took was analogous to what is done in the customizer (surprise), where if the widget is not saved yet then the button says “Save” as it does currently, but once the widget has been updated (and the `widget-updated` event triggers) then the button becomes `disabled` and the text changes to “Saved”. Upon making another change to the widget, then the button becomes enabled again and the text returns to “Save”. In the case of an HTTP error, then the enabled Save button just will never turn to Saved. If the `WP_JS_Widget` failed a validation constraint, then the button would remain “Save” but a validation notification would appear in the control.
    22
    33See [attachment:saved-button-state.png] and corresponding plugin commit: https://github.com/xwp/wp-js-widgets/commit/878b422e4c911bf80ce067ddd2a77cf110a7338b