Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 5.4.3 into next #10425

Merged
merged 46 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dfc2d39
Update AccordionForm documentation
djhi Dec 11, 2024
33ae7f5
Update LongForm documentation
djhi Dec 11, 2024
af9672a
Update WizardForm documentation
djhi Dec 11, 2024
cbf50e9
Update OSS forms documentation
djhi Dec 11, 2024
195d26f
Update TabbedShowLayout documentation
djhi Dec 11, 2024
8560ea5
Improve OSS forms documentation
djhi Dec 11, 2024
247c03d
Remove mentions of useGetPermissions
djhi Dec 11, 2024
7183b49
Revert TabbedShowLayout changes
djhi Dec 11, 2024
8fc91f6
Improve SimpleShowLayout [no ci]
djhi Dec 11, 2024
9fe472c
Document Menu Access Control [no ci]
djhi Dec 11, 2024
c76da1c
Document CloneButton and ExportButton [no ci]
djhi Dec 11, 2024
bbd922c
Update Datagrid documentation [no ci]
djhi Dec 11, 2024
a551e35
Update RBAC documentation [no ci]
djhi Dec 11, 2024
725c236
Update DatagridAG documentation
djhi Dec 11, 2024
0724e49
Fix snippets
djhi Dec 11, 2024
2ec4722
Apply suggestions from code review
djhi Dec 12, 2024
809641a
Apply suggestions from code review
djhi Dec 12, 2024
d7e8d33
Fix link typo
djhi Dec 12, 2024
307c293
Merge pull request #10410 from marmelab/update-datagrid-ag-documentation
fzaninotto Dec 12, 2024
4308f7c
Improve introduction
fzaninotto Dec 12, 2024
40b374d
Document Datagrid access control in Datagrid doc
fzaninotto Dec 12, 2024
a98cd5a
Move the List RBAC features to the List doc
fzaninotto Dec 12, 2024
c2b7550
Move SimpleShowLayout RBAC doc to SimpleShowLayout chapter
fzaninotto Dec 12, 2024
5a33cfd
Move Simpleform RBAC doc to SimpleForm chapter
fzaninotto Dec 12, 2024
ff42f32
Move Menu RBAC doc to the Menu chapter
fzaninotto Dec 12, 2024
30ff4d3
Move TabbedShowLayout RBAC doc to TabbedshowLayout chapter
fzaninotto Dec 12, 2024
3011173
Move TabbedForm RBAC doc to TabbedForm chapter
fzaninotto Dec 12, 2024
7f60ef3
Move RBAC buttons doc to the Buttons chapter
fzaninotto Dec 12, 2024
0c71fe8
Add mention of built-in access control
fzaninotto Dec 12, 2024
1a96836
MAke access control section position consistent
fzaninotto Dec 12, 2024
babc4d5
Merge pull request #10409 from marmelab/update-rbac-documentation
fzaninotto Dec 12, 2024
c916284
Bump nanoid from 3.3.7 to 3.3.8
dependabot[bot] Dec 15, 2024
bdf5cce
Merge pull request #10414 from marmelab/dependabot/npm_and_yarn/nanoi…
fzaninotto Dec 15, 2024
8c01e20
[Doc] Remove `<ShowBase emptyWhileLoading>` from the docs
slax57 Dec 16, 2024
526d088
Merge pull request #10416 from marmelab/doc-ShowBase-emptyWhileLoading
djhi Dec 16, 2024
fa523be
Add a FormDataConsumer showing the issue
djhi Dec 16, 2024
08f256b
Fix FormDataConsumer
djhi Dec 16, 2024
5d339c8
Add comment [no ci]
djhi Dec 16, 2024
b05a1a0
[no ci] minor improvements to story
slax57 Dec 17, 2024
d135bd3
Merge pull request #10417 from marmelab/fix-form-data-consumer-flicker
slax57 Dec 17, 2024
a25733d
Update changelog for 5.4.3
djhi Dec 18, 2024
9e441c2
v5.4.3
djhi Dec 18, 2024
dabb850
Update yarn.lock for 5.4.3
djhi Dec 18, 2024
fef8540
Fix `useUpdate` ignores `meta` when populating the query cache in pes…
slax57 Dec 18, 2024
a1b7be0
Merge pull request #10422 from marmelab/fix-useUpdate-pessimistic-cac…
djhi Dec 19, 2024
ad6bf18
Merge branch 'master' into next
djhi Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix FormDataConsumer
  • Loading branch information
djhi committed Dec 16, 2024
commit 08f256b0b7a2f9d954fb056070b51c7b0f6a54cc
29 changes: 17 additions & 12 deletions packages/ra-core/src/form/FormDataConsumer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useFormContext, FieldValues } from 'react-hook-form';
import get from 'lodash/get';
import { useFormValues } from './useFormValues';
import { useWrappedSource } from '../core';
import { useEvent } from '../util';

/**
* Get the current (edited) value of the record from the form and pass it
Expand Down Expand Up @@ -67,22 +68,26 @@ export const FormDataConsumerView = <
props: Props<TFieldValues>
) => {
const { children, formData, source } = props;
let ret;
const [result, setResult] = React.useState<ReactNode>(null);

const finalSource = useWrappedSource(source || '');
const render = useEvent(children);

// Passes an empty string here as we don't have the children sources and we just want to know if we are in an iterator
const matches = ArraySourceRegex.exec(finalSource);
// Getting the result of the children function in a useEffect allows us to keep a stable reference to is
// with useEvent
React.useEffect(() => {
// Passes an empty string here as we don't have the children sources and we just want to know if we are in an iterator
const matches = ArraySourceRegex.exec(finalSource);
// If we have an index, we are in an iterator like component (such as the SimpleFormIterator)
if (matches) {
const scopedFormData = get(formData, matches[0]);
setResult(render({ formData, scopedFormData }));
} else {
setResult(render({ formData }));
}
}, [finalSource, formData, render]);

// If we have an index, we are in an iterator like component (such as the SimpleFormIterator)
if (matches) {
const scopedFormData = get(formData, matches[0]);
ret = children({ formData, scopedFormData });
} else {
ret = children({ formData });
}

return ret === undefined ? null : ret;
return result;
};

const ArraySourceRegex = new RegExp(/.+\.\d+$/);
Expand Down
Loading