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

Commit cac7470

Browse files
authored
Merge pull request #341 from xwp/issue/35
Focus on specific field that have conflict
2 parents f7f5c98 + 8651519 commit cac7470

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

js/customize-post-section.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,8 @@
891891

892892
// Detect conflict errors.
893893
api.bind( 'error', function( response ) {
894-
var theirValue, ourValue;
894+
var theirValue, ourValue,
895+
conflictedControls = [];
895896
if ( ! response.update_conflicted_setting_values ) {
896897
return;
897898
}
@@ -912,8 +913,22 @@
912913
} );
913914
control.notifications.remove( notification.code );
914915
control.notifications.add( notification.code, notification );
916+
conflictedControls.push( control );
915917
}
916918
} );
919+
920+
// Focus on first field that have conflict.
921+
if ( section.expanded() ) {
922+
_.every( section.controls(), function( _setting ) {
923+
return _.every( conflictedControls, function( conflictedControl ) {
924+
if ( conflictedControl.id === _setting.id ) {
925+
_setting.focus();
926+
return false;
927+
}
928+
return true;
929+
} );
930+
} );
931+
}
917932
} );
918933

919934
api.bind( 'save', function() {

0 commit comments

Comments
 (0)