Skip to content

Commit

Permalink
fix: provide empty readOnly object instead of undefined to root resol…
Browse files Browse the repository at this point in the history
…veFields
  • Loading branch information
chrisvxd committed Jan 29, 2025
1 parent b7ff689 commit 8992a94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/core/lib/__tests__/use-resolved-fields.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("use-resolved-fields", () => {
expect(mockResolveFields).toHaveBeenCalledWith(
{
props: {},
readOnly: undefined,
readOnly: {},
},
{
appState: {
Expand Down Expand Up @@ -230,7 +230,7 @@ describe("use-resolved-fields", () => {
expect(mockResolveFields).toHaveBeenCalledWith(
{
props: {},
readOnly: undefined,
readOnly: {},
},
{
appState: {
Expand Down Expand Up @@ -280,15 +280,15 @@ describe("use-resolved-fields", () => {
expect(result.current[1]).toBe(false);
expect(mockResolveFields).toHaveBeenCalledTimes(2);
expect(mockResolveFields.mock.calls[1]).toEqual([
{ props: { foo: "bar" }, readOnly: undefined },
{ props: { foo: "bar" }, readOnly: {} },
{
appState: {
data: { content: [], root: { props: { foo: "bar" } } }, // props changed
ui: { itemSelector: null },
},
changed: { foo: true }, // track changed
fields: { title: { type: "text" } },
lastData: { props: {}, readOnly: undefined },
lastData: { props: {}, readOnly: {} },
lastFields: { title: { type: "textarea" } }, // track previous fields due to re-render
parent: null,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/lib/use-resolved-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const useResolvedFields = (): [FieldsType, boolean] => {
() =>
selectedItem
? selectedItem
: { props: rootProps, readOnly: data.root.readOnly },
: { props: rootProps, readOnly: data.root.readOnly || {} },
[selectedItem, rootProps, data.root.readOnly]
);

Expand Down

0 comments on commit 8992a94

Please sign in to comment.