Skip to content

Commit

Permalink
pass storeKey down from RepeatableFieldList to SubFieldWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Shelob9 committed Jul 10, 2023
1 parent a1a10e3 commit fd5e633
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const RepeatableFieldList = ( {
allPodFieldsMap,
setFullValue,
setHasBlurred,
storeKey,
} ) => {
// Helper functions for setting, moving, adding, and deleting the value
// or subvalues.
Expand Down Expand Up @@ -203,6 +204,7 @@ const RepeatableFieldList = ( {
/>
) : null }
key={ `${ fieldConfig.name }-${ index }` }
storeKey={ storeKey }
/>
);
} ) }
Expand Down Expand Up @@ -276,6 +278,11 @@ RepeatableFieldList.propTypes = {
* Function to call when a field has blurred.
*/
setHasBlurred: PropTypes.func.isRequired,

/**
* Redux store key.
*/
storeKey: PropTypes.string.isRequired,
};

export default RepeatableFieldList;
13 changes: 10 additions & 3 deletions ui/js/dfv/src/components/field-wrapper/subfield-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const SubfieldWrapper = ( {
allPodFieldsMap,
setValue,
setHasBlurred,
storeKey,
} ) => {
// Adjust the `name`/`htmlAttr[name]` and IDs
// for repeatable fields, so that each value gets saved.
Expand Down Expand Up @@ -70,7 +71,8 @@ const SubfieldWrapper = ( {
const [ validationMessages, addValidationRules ] = useValidation(
[],
value,
subfieldConfig.name
subfieldConfig.name,
storeKey
);

// Set up useSortable hook
Expand Down Expand Up @@ -189,7 +191,7 @@ SubfieldWrapper.propTypes = {

/**
* Pod slug being edited.
*/
*/
podName: PropTypes.string,

/**
Expand All @@ -210,8 +212,13 @@ SubfieldWrapper.propTypes = {

/**
* Function to call when a field has blurred.
*/
*/
setHasBlurred: PropTypes.func.isRequired,

/**
* Redux store key.
*/
storeKey: PropTypes.string.isRequired,
};

export default SubfieldWrapper;
2 changes: 0 additions & 2 deletions ui/js/dfv/src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const initEditPodStore = ( config, storeKey = '' ) => {
},
...omit( config, [ 'fieldTypes', 'relatedObjects' ] ),
};
console.log({initEditPodStore:initialState});
return initStore( initialState, storeKey );
};

Expand All @@ -97,7 +96,6 @@ export const initPodStore = ( config = {}, initialValues = {}, storeKey = '' ) =
...omit( config, [ 'fieldTypes', 'relatedObjects' ] ),
currentPod: initialValues,
};
console.log({initPodStore:initialState});

return initStore( initialState, storeKey );
};

0 comments on commit fd5e633

Please sign in to comment.