Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Focus on specific field that have conflict #341

Merged
merged 2 commits into from
Jan 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion js/customize-post-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,8 @@

// Detect conflict errors.
api.bind( 'error', function( response ) {
var theirValue, ourValue;
var theirValue, ourValue,
conflictedControls = [];
if ( ! response.update_conflicted_setting_values ) {
return;
}
Expand All @@ -912,8 +913,22 @@
} );
control.notifications.remove( notification.code );
control.notifications.add( notification.code, notification );
conflictedControls.push( control );
}
} );

// Focus on first field that have conflict.
if ( section.expanded() ) {
_.every( section.controls(), function( _setting ) {
return _.every( conflictedControls, function( conflictedControl ) {
if ( conflictedControl.id === _setting.id ) {
_setting.focus();
return false;
}
return true;
} );
} );
}
} );

api.bind( 'save', function() {
Expand Down