From 8651519e7fffd4836d14a76bf74eb2d4cff07ad9 Mon Sep 17 00:00:00 2001 From: Utkarsh Patel Date: Mon, 23 Jan 2017 16:52:33 +0530 Subject: [PATCH] Fix conflict issue when control order is changed --- js/customize-post-section.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/js/customize-post-section.js b/js/customize-post-section.js index 473fa22..3674b49 100644 --- a/js/customize-post-section.js +++ b/js/customize-post-section.js @@ -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; } @@ -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() {