Skip to content

Commit

Permalink
Fix pod value default handling for new fields/groups modals to preven…
Browse files Browse the repository at this point in the history
…t messing with Pod state
  • Loading branch information
sc0ttkclark committed Mar 23, 2024
1 parent 821a6d4 commit 91eb465
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ui/js/blocks/pods-blocks-api.min.asset.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"dependencies":["lodash","react","react-dom","wp-api-fetch","wp-autop","wp-block-editor","wp-blocks","wp-components","wp-compose","wp-date","wp-element","wp-i18n","wp-keycodes","wp-server-side-render","wp-url"],"version":"36833f64db81bafbf328"}
{"dependencies":["lodash","react","react-dom","wp-api-fetch","wp-autop","wp-block-editor","wp-blocks","wp-components","wp-compose","wp-date","wp-element","wp-i18n","wp-keycodes","wp-server-side-render","wp-url"],"version":"093a1202eff12a66463c"}
2 changes: 1 addition & 1 deletion ui/js/blocks/pods-blocks-api.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/js/dfv/pods-dfv.min.asset.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"dependencies":["lodash","moment","react","react-dom","wp-api-fetch","wp-autop","wp-components","wp-compose","wp-data","wp-element","wp-hooks","wp-i18n","wp-keycodes","wp-plugins","wp-polyfill","wp-primitives","wp-url"],"version":"697d8b495e03a75eabdd"}
{"dependencies":["lodash","moment","react","react-dom","wp-api-fetch","wp-autop","wp-components","wp-compose","wp-data","wp-element","wp-hooks","wp-i18n","wp-keycodes","wp-plugins","wp-polyfill","wp-primitives","wp-url"],"version":"8de35a288f74331f4ef2"}
2 changes: 1 addition & 1 deletion ui/js/dfv/pods-dfv.min.js

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions ui/js/dfv/src/components/field-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ const FieldSet = ( {
// When the set first mounts, apply any defaults to replace any undefined values
// (NOT falsy values).
useEffect( () => {
const allDefaultValues = {};

fields.forEach( ( field ) => {
const {
type: fieldType,
Expand All @@ -46,18 +44,16 @@ const FieldSet = ( {
'undefined' === typeof allPodValues[ subField.name ] &&
null !== subField?.default
) {
allDefaultValues[ subField.name ] = subField?.default ?? '';
allPodValues[ subField.name ] = subField?.default ?? '';
}
} );
} else if (
'undefined' === typeof allPodValues[ fieldName ] &&
null !== field?.default
) {
allDefaultValues[ fieldName ] = field?.default ?? '';
allPodValues[ fieldName ] = field?.default ?? '';
}
} );

setOptionsValues( allDefaultValues );
}, [] );

return fields.map( ( field ) => {
Expand Down

0 comments on commit 91eb465

Please sign in to comment.