payload icon indicating copy to clipboard operation
payload copied to clipboard

In the List Filter UI, the filter value is not invalidated when the field or operator is changed. Possibly crashing with a Range Error.

Open mfilteau opened this issue 1 year ago • 7 comments

Describe the Bug

In the List Filter UI, after adding a filter condition with field name, operator and value, if the user changes the filter name or operator, the value is not invalidated.

Some values may not be compatible with the new field / operator combination and the UI either crashes or the filter is unusable.

Image

Link to the code that reproduces this issue

https://github.com/mfilteau/payload-bugs

Reproduction Steps

  1. Seed the database

http://localhost:3000/api/seed

  1. In the admin panel, go to Orders

  2. Open the List Filter and add a filter for the Date with operator "Exists" and value "True"

  3. Change the operator to 'Equals'

-> the UI will crash with a Range Error

The same issue can be demonstrated when the value is a drop-down list populated for a relationship field. The content of the drop-down doesn't change.

https://github.com/user-attachments/assets/baba4b1b-add9-47ef-9acf-7447041c2982 https://github.com/user-attachments/assets/cf084516-3eaa-489e-914b-5f77944619cd

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

area: ui

Environment Info

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

mfilteau avatar Jan 17 '25 20:01 mfilteau

Hi @mfilteau - I have opened a PR to fix this issue here. We aim to get this merged soon, thank you for reporting this.

JessRynkar avatar Feb 12 '25 15:02 JessRynkar

Hi @JessChowdhury,

I see how the PR fixes the first issue. I'm not sure about the second one. When you move from one relationship field to another, and the list of values is not updated.

https://github.com/user-attachments/assets/cf084516-3eaa-489e-914b-5f77944619cd

mfilteau avatar Feb 13 '25 15:02 mfilteau

Hi @mfilteau, you're right the fix in that PR will not resolve the relationship value bug - this issue is caused by something else.

I'm going to open a new issue from your comment above so we can track both issues separately and to ensure it does not get lost when the linked PR merges.

EDIT: I did open a separate PR but am going to close now until we can replicate.

JessRynkar avatar Feb 13 '25 16:02 JessRynkar

I am unable to reproduce the relationship filter bug that you showed in your video, it's possible this was resolved in recent changes to the whereBuilder - could you upgrade to the latest release v.3.23.0 and see if you get the same behavior?

https://github.com/user-attachments/assets/675cc254-fabc-4a9f-948f-a5fc609a65a2

JessRynkar avatar Feb 13 '25 16:02 JessRynkar

Hi @JessChowdhury, you're absolutely right. This has been fixed in 3.23 by https://github.com/payloadcms/payload/pull/11080

Once your PR is merged, this issue will be closed for me.

Thanks a lot!

mfilteau avatar Feb 13 '25 18:02 mfilteau

🚀 This is included in version v3.34.0

github-actions[bot] avatar Apr 10 '25 19:04 github-actions[bot]

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Apr 18 '25 05:04 github-actions[bot]