Opened 8 years ago
Closed 8 years ago
#39770 closed defect (bug) (fixed)
Customize: Client-side notification error is unexpectedly cleared when no corresponding server-side validation
Reported by: | westonruter | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.7.4 | Priority: | low |
Severity: | normal | Version: | 4.6 |
Component: | Customize | Keywords: | has-patch commit fixed-major |
Focuses: | Cc: |
Description
Setting validation can be added both by adding a validate_callback
(or sanitize_callback
) on the server, or it can be added by adding an error Notification
via JS (see also Make/Core post):
wp.customize( 'blogdescription', function( setting ) { var errorCode = 'capital_P_dangit'; setting.bind( function( value ) { var notification; if ( /[Ww]ordpress/.test( value ) ) { notification = new wp.customize.Notification( errorCode, { type: 'error', message: 'Capital P Dangit!' } ); setting.notifications.add( errorCode, notification ); } else { setting.notifications.remove( errorCode ); } } ); } );
However, if the server lacks corresponding validation (which normally it should) the setting is currently marked as valid on the server and the error
gets unexpectedly cleared on the client.
Attachments (1)
Change History (11)
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by swissspidy. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by swissspidy. View the logs.
8 years ago
#6
@
8 years ago
- Owner set to westonruter
- Status changed from new to assigned
@westonruter Is this ready for a commit?
Note: See
TracTickets for help on using
tickets.
In order for returning an error/notification to work properly, api._handleSettingValidities needs to only remove notification errors that are no longer valid which are
fromServer
. See 39770.0.diff.