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

Commit

Permalink
Fix conflict issue when control order is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
PatelUtkarsh committed Jan 23, 2017
1 parent d9fae37 commit 8651519
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions js/customize-post-section.js
Expand Up @@ -892,7 +892,7 @@
// Detect conflict errors.
api.bind( 'error', function( response ) {
var theirValue, ourValue,
isFirstConflict = true;
conflictedControls = [];
if ( ! response.update_conflicted_setting_values ) {
return;
}
Expand All @@ -913,12 +913,22 @@
} );
control.notifications.remove( notification.code );
control.notifications.add( notification.code, notification );
}
if ( api.section( control.section() ).expanded() && isFirstConflict ) {
control.focus();
isFirstConflict = false;
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

0 comments on commit 8651519

Please sign in to comment.