Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
Forgot to assign values to updated value
  • Loading branch information
micahjon committed Oct 31, 2023
1 parent 354d5d6 commit 767ecd5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rhf-conditional-logic",
"version": "0.0.1-alpha.3",
"version": "0.0.1-alpha.4",
"main": "./dist/rhf-conditional-logic.cjs",
"module": "./dist/rhf-conditional-logic.mjs",
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ export function pruneHiddenFields<
);

// Remove hidden values
const values = getValues();
let values = getValues();
for (const fieldName in formFieldVisibility) {
const isHidden =
formFieldVisibility[fieldName as TFieldNames[number]] === false;
if (isHidden) {
deleteByPathWithoutMutation(values, fieldName);
values = deleteByPathWithoutMutation(values, fieldName) as TFieldValues;
}
}
return values;
Expand Down
7 changes: 5 additions & 2 deletions tests-e2e/mock-form/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ export function Form() {
formState: { errors },
} = formMethods;

const onSubmit = data => {
console.log("Successfully submitted", data as FormSchema);
const onSubmit = () => {
console.log(
"Successfully submitted",
pruneHiddenFields(conditions, formMethods.getValues) as FormSchema
);
};

const { otherCaterer: showOtherCaterer } = useConditionalLogic(
Expand Down

0 comments on commit 767ecd5

Please sign in to comment.