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

fields.date and fields.datetime brokes document editing #1266

Closed
adamjosefus opened this issue Aug 15, 2024 · 1 comment
Closed

fields.date and fields.datetime brokes document editing #1266

adamjosefus opened this issue Aug 15, 2024 · 1 comment

Comments

@adamjosefus
Copy link
Contributor

adamjosefus commented Aug 15, 2024

When I have date or datetime field in a schema, the editing procces broke.

Work OK, but I need a date.

export const MyComponenet = component({
  label: 'Registrace na REJUMP',
  preview: (props) => {
    return <pre>{JSON.stringify(props, null, 2)}</pre>;
  },
  schema: {
    // startDate: fields.date({
    //   label: 'My Date',
    // }),
    price: fields.integer({
      label: 'My Price',
      defaultValue: 0,
      validation: {
        isRequired: true,
        min: 1,
      },
    }),
  },
});

After adding this component to the document, Editor will trigger document modification → "Unsave" badge appears.

export const MyComponenet = component({
  label: 'Registrace na REJUMP',
  preview: (props) => {
    return <pre>{JSON.stringify(props, null, 2)}</pre>;
  },
  schema: {
+     startDate: fields.date({
+       label: 'My Date',
+     }),
    price: fields.integer({
      label: 'My Price',
      defaultValue: 0,
      validation: {
        isRequired: true,
        min: 1,
      },
    }),
  },
});

But after click to "Save" button, whole editor creashed.
Snímek obrazovky 2024-08-15 v 16 30 11

When I add an initial value to the date schema, the editor does not crash. But editor nocognize a change. If I trigger the change something else then this component disaperea after saving.

export const MyComponenet = component({
  label: 'Registrace na REJUMP',
  preview: (props) => {
    return <pre>{JSON.stringify(props, null, 2)}</pre>;
  },
  schema: {
    startDate: fields.date({
      label: 'My Date',
+      defaultValue: { kind: 'today' },
    }),
    price: fields.integer({
      label: 'My Price',
      defaultValue: 0,
      validation: {
        isRequired: true,
        min: 1,
      },
    }),
  },
});

Dependencies

  • @keystatic/core: 0.5.32,
  • @keystatic/next: 5.0.1
@adamjosefus adamjosefus changed the title fields.date and fields.datetime brokes t fields.date and fields.datetime brokes document editing Aug 15, 2024
@adamjosefus
Copy link
Contributor Author

mdx fixed that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant