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

Bug in error validation error message #11260

Open
Arctomachine opened this issue Feb 18, 2025 · 7 comments
Open

Bug in error validation error message #11260

Arctomachine opened this issue Feb 18, 2025 · 7 comments

Comments

@Arctomachine
Copy link
Contributor

Describe the Bug

Two issues:

  1. Error message is not displayed on field at small screens (1024px and less)
  2. Toast message for nested field error uses field names instead of labels (but field itself uses label)

Link to the code that reproduces this issue

https://github.com/Arctomachine/payload-nested-field-validation-message-bug.git

Reproduction Steps

For provided reproduction:

  1. Set screen size to be below 1025px wide
  2. Start server, go to admin panel, go to test collection
  3. Create new document and try to save

Observe toast message giving field names instead of labels.

Make screen wider and see error message for field working as expected.

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

area: ui

Environment Info

Binaries:
  Node: 23.7.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.23.0
  next: 15.1.5
  @payloadcms/db-mongodb: 3.23.0
  @payloadcms/email-nodemailer: 3.23.0
  @payloadcms/graphql: 3.23.0
  @payloadcms/next/utilities: 3.23.0
  @payloadcms/payload-cloud: 3.23.0
  @payloadcms/richtext-lexical: 3.23.0
  @payloadcms/translations: 3.23.0
  @payloadcms/ui/shared: 3.23.0
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 32720
  Available CPU cores: 12
@Arctomachine Arctomachine added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction labels Feb 18, 2025
@JessChowdhury JessChowdhury self-assigned this Feb 20, 2025
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Feb 20, 2025
@JessChowdhury
Copy link
Member

@Arctomachine thank you for the solid reproduction! I am looking into this now.

@JessChowdhury
Copy link
Member

JessChowdhury commented Feb 20, 2025

Can't reproduce this on my system / browser combination. What browser are you using when you get this behavior?

Screen.Recording.2025-02-20.at.11.58.43.AM.mov

@JessChowdhury JessChowdhury added the status: cant-reproduce If an issue cannot be reproduced label Feb 20, 2025
@Arctomachine
Copy link
Contributor Author

Arctomachine commented Feb 20, 2025

You reproduced everything right.

  1. Error message should appear on right side above field, should say "must be test"
  2. Toast should say "top level group label > nested group label > field label"

@JessChowdhury JessChowdhury removed the status: cant-reproduce If an issue cannot be reproduced label Feb 20, 2025
@JessChowdhury
Copy link
Member

Wow my brain must not have been turned on - I see the issue now, working on it! Thanks for the patience 😂

@JessChowdhury
Copy link
Member

Here is what I've found:

  1. The field error message is intentionally hidden on smaller screen screens (below 1024px width), it has been determined better UI to only show the error pill indicator.
  2. The toast notification is failing to show labels for any parent paths. This is not related to window size, it is happening at all sizes but only happens with parent paths.

So the fixable issue here is those parent path labels, it should show labels instead of field names when possible. I have a fix in progress and will get a PR open shortly after adding tests.

@Arctomachine
Copy link
Contributor Author

Hiding error message may be good for default validation. But what about custom validation? How can user know what is wrong with data in field?
For example, in this reproduction can you reliably know that field expects value "test" in it? Description could say it explicitly for this simple validation, but what if there were conditions? How to know which of them is violated without reading error message?

@JessChowdhury
Copy link
Member

@Arctomachine I definitely understand the potential need but as this is intended behavior it won't be fixed as a bug. I'll get a feature request open regarding full error message output on smaller screens - it would be nice to have this available as opt-in behavior or something similar.

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

No branches or pull requests

2 participants