Skip to content

Commit fa25fe7

Browse files
authored
Merge pull request #2252 from siteorigin/builder-field-backup-changes
sowFieldBackups Builder Changes
2 parents 71f1b89 + 157592a commit fa25fe7

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

base/js/admin.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,8 @@ var sowbForms = window.sowbForms || {};
13291329
// Exclude keys that are not relevant for field value comparison.
13301330
if (
13311331
key === '_sow_form_timestamp' ||
1332-
key === '_sow_form_id'
1332+
key === '_sow_form_id' ||
1333+
key === 'builder_id'
13331334
) {
13341335
return false;
13351336
}
@@ -1406,12 +1407,47 @@ var sowbForms = window.sowbForms || {};
14061407
// Add user change detection to the form to prevent unintended
14071408
// backups of automated changes.
14081409
$el.on( 'keydown mouseup touchend', ( e ) => {
1410+
if ( isUserChange ) {
1411+
return;
1412+
}
1413+
1414+
const $target = $( e.target );
1415+
14091416
// Don't trigger a backup if the user clicked on a section.
1410-
if ( $( e.target ).parent().is( '.siteorigin-widget-field-type-section' ) ) {
1417+
if ( $target.is( 'label' ) ) {
1418+
const $parent = $target.parent();
1419+
// Check if the label is part of a section/widget field.
1420+
if (
1421+
$parent.hasClass( 'siteorigin-widget-field-type-section' ) ||
1422+
$parent.hasClass( 'siteorigin-widget-field-type-widget' )
1423+
) {
1424+
return false;
1425+
}
1426+
}
1427+
1428+
// Don't trigger if user opens Builder field.
1429+
if ( $target.is( '.siteorigin-panels-display-builder' ) ) {
14111430
return false;
14121431
}
14131432

1414-
isUserChange = true;
1433+
const validElementClasses = [
1434+
'input',
1435+
'select',
1436+
'textarea',
1437+
'iframe',
1438+
'label',
1439+
'.ui-slider-handle',
1440+
'.ui-slider',
1441+
'.siteorigin-widget-icon-icons-icon',
1442+
'.so-panels-dialog-add-builder .so-close',
1443+
'a.media-upload-button',
1444+
'a.media-remove-button',
1445+
];
1446+
1447+
if ( validElementClasses.some( ( selector ) => $target.is( selector ) ) ) {
1448+
isUserChange = true;
1449+
}
1450+
14151451
} );
14161452

14171453
// Debounce backups to prevent potential performance issues.

0 commit comments

Comments
 (0)