Relationship filterOptions does not update accordingly. #12187
Replies: 5 comments
-
Here are two recordings to try and illustrate the issue. Take note of how after certain actions, the option to select something which should be selectable disappears. There's a few funky things going on there, but I think the picture can provide more clarity than words. 2024-05-16.11-15-58.mp42024-05-16.11-22-20.mp4 |
Beta Was this translation helpful? Give feedback.
-
This issue has been marked as stale due to lack of activity. To keep this issue open, please indicate that it is still relevant in a comment below. |
Beta Was this translation helpful? Give feedback.
-
This issue was automatically closed due to lack of activity. |
Beta Was this translation helpful? Give feedback.
-
Also facing this issue, +1 |
Beta Was this translation helpful? Give feedback.
-
You can handle this with a custom component on the collection. Without rewriting the relationship field you could use a type UI field that just uses form hooks to watch for the change and sets the value of uploads if your condition is met. There are loads of scenarios where validation logic changes and you get an error only when trying to save. I don't consider this an issue so I will convert to a discussion. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In the following reproduction, I have a collection of
Movie
,Theatre
andUpload
.An
Upload
belongs to aTheatre
.A
Movie
is owned by aTheatre
.An
Upload
should only be assignable to aMovie
, where theMovie
'smovie.theatre
id is equal to theupload.theatre
id.As it stands, the following code works out for this logic:
However, If you have
TheatreA
selected, and selectUploadA
, then changevideo.theatre
toTheatreB
,UploadA
is not removed. The user experience is seemingly impossible to make reasonable, with making entirely custom field components. You can play around with it and see numerous scenarios where thefilterOptions
is not fixed until refreshing the page, as well. For example, it's possible to have bothUploadA
andUploadB
selectable in the select component, which should certainly never happen.I believe that in this scenario, it should not only ensure that the
filterOptions
are always correct, but it should remove a selected item, if it's not present in thefilterOptions
.If you'd like to clone the reproduction, to easily play around with this, you can follow these instructions:
git clone -b filter-options-wont-update https://github.com/HarleySalas/payload-3-reproductions.git
pnpm install
.env.example
to.env
docker-compose up
pnpm dev
Movie
There is no need to modify anything inside of
.env
. All necessary data will be seeded.Beta Was this translation helpful? Give feedback.
All reactions