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

Custom Text Field Server Component doesn't has value #10389

Open
GeorgeHulpoi opened this issue Jan 6, 2025 · 2 comments
Open

Custom Text Field Server Component doesn't has value #10389

GeorgeHulpoi opened this issue Jan 6, 2025 · 2 comments
Labels
created-by: Contributor status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@GeorgeHulpoi
Copy link
Contributor

Describe the Bug

Based on the docs:
Image
Therefore, the Server Component should have value. Nonetheless, the TextFieldServerComponent doesn't contain value type and is undefined.

Link to the code that reproduces this issue

https://github.com/GeorgeHulpoi/payload-custom-field-bug/tree/main

Reproduction Steps

  1. Create a user (it should show abc [the default value]).
  2. Go to the users -> your user
  3. It should show value: abc, but it shows value:

Which area(s) are affected? (Select all that apply)

area: core, area: ui

Environment Info

Binaries:     
  Node: 20.9.0
  npm: N/A    
  Yarn: N/A   
  pnpm: N/A   
Relevant Packages:
  payload: 3.14.0
  next: 15.1.0
  @payloadcms/db-mongodb: 3.14.0
  @payloadcms/email-nodemailer: 3.14.0
  @payloadcms/graphql: 3.14.0
  @payloadcms/next/utilities: 3.14.0
  @payloadcms/payload-cloud: 3.14.0
  @payloadcms/richtext-lexical: 3.14.0
  @payloadcms/translations: 3.14.0
  @payloadcms/ui/shared: 3.14.0
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 14189
  Available CPU cores: 16
@akhrarovsaid
Copy link
Contributor

Hey @GeorgeHulpoi,

Yeah, this seems to me to be a documentation issue more than a bug in ui, at least to me, to be honest. I say that because while value & initialValue aren't included in the default serverProps at this time, you get a few excellent workarounds. I think either value & initialValue might be included at some point, or they've been omitted in favor of formState which has both properties and more.

In any case, you can use either of the data or formState props passed directly to your component to get the data you need to render your component properly.

I also noticed you're explicitly typing your props in your repro as any which isn't needed and would catch that value doesn't exist in the props. The TextFieldServerComponent is sufficient here.

@GeorgeHulpoi
Copy link
Contributor Author

Hey @GeorgeHulpoi,

Hello mate!

Yeah, this seems to me to be a documentation issue more than a bug in ui, at least to me, to be honest. I say that because while value & initialValue aren't included in the default serverProps at this time, you get a few excellent workarounds. I think either value & initialValue might be included at some point, or they've been omitted in favor of formState which has both properties and more.

Seems like the team wrote the docummentation based on what they wanted to do 😄

In any case, you can use either of the data or formState props passed directly to your component to get the data you need to render your component properly.

Yeah, but it should be done by Payload. Searching in a object based on path isn't elegant nor fit for end-user.

I also noticed you're explicitly typing your props in your repro as any which isn't needed and would catch that value doesn't exist in the props. The TextFieldServerComponent is sufficient here.

It's a reproduction bug ¯_(ツ)_/¯, TextFieldServerComponent doesn't contain value, thus I had to cast to any. Sometimes a property is not typed, but exists in runtime object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Contributor status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants