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

fix(ui): gracefully handle deletions in collection with upload hasMany #9426

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

akhrarovsaid
Copy link
Contributor

@akhrarovsaid akhrarovsaid commented Nov 22, 2024

What?

This PR aims to prevent a runtime error by allowing deletions in media collections and preventing them from impacting workflows while using hasMany upload fields.

Why?

To prevent runtime issues during common tasks.

How?

By treating deleted media documents as empty placeholders instead of undefined objects.

Fixes #9328

Before:
Dashboard-before--Payload.webm

After:
Dashboard-after--Payload.webm

Notes:

  • There is room for improvement here: allow selection of existing media in upload collection instead of forcing user to upload new. Workaround is to remove the row and choose existing as usual.
  • New uploads chosen will always replace the first instance of undefined placeholder due to the simple check. If you have 3 deleted entries and open the drawer on the second one, then it will populate the first one anyway. This can be improved but will require more laborious code changes.
  • Noticed an issue where deleted non-hasMany upload fields do not re-render after a file is uploaded. It only shows the previous deleted doc, ie id: "untitled - ID: ...". Re-renders correctly when choosing from existing. This is unrelated to this PR. I will investigate further.

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

Successfully merging this pull request may close these issues.

Deleted media that included in upload field hasMany, showing undefined id in admin panel
1 participant