payload icon indicating copy to clipboard operation
payload copied to clipboard

DRAFT: fix(richtext-lexical): link drawers nested in link drawers not functioning properly

Open AlessioGr opened this issue 2 years ago • 0 comments

Description

TODO:

  • [ ] Remove unnecessary changes in test suite
  • [ ] Figure out DX for people who want to add custom fields with, let's say, conditions to other fields. Instead of being able to do data.fields.someField, they now have to do data.linkDrawer_fields_someuuidhere.someField while not knowing the uuid. This is also an issue for the Blocks field
  • [ ] Both Links, Blocks and Uploads are now doing this wrapping-in-custom-group. Every time it's done in a slightly different way → figure out a uniform way to handle this. On load, the group wrapping needs to happen for both field schema and field data. On save, group unwrapping needs to happen for field data. Maybe there instead needs to be a smart way inside of the form to handle that, instead of manually doing group wrapping and unwrapping. Some kind of fieldsParentPathName or something like that which can be set inside of the form and affects the paths of all sub-fields (as that's what causes radio buttons with identical path to not work anymore).
  • [ ] Add 4 e2e tests:
    • [ ] Saving and loading data from link drawer fields
    • [ ] Saving and loading data from Upload drawer extra fields
    • [ ] Using the conditional radio fields in a link drawer inside of a link drawer (what this issue fixes)
    • [ ] Using the conditional radio fields in an upload drawer inside of an upload drawer (what this issue fixes)
  • [ ] Unrelated, but I find fields being used in Form stuff (e.g. Form fields property) to be confusing. It could mean both field schema and field data. Maybe we can rename every mention of fields to either fieldSchema or fieldData (similar to what the buildStateFromSchema function accepts)

https://github.com/payloadcms/payload/assets/70709113/b3ca8638-ea96-4833-9626-e8cac43d8be1

This video shows the issue which this PR fixed. Nested Link drawer fields do not work properly because they are wrapped in a group which is not unique. Appending the uuid to the group's field name fixes this.

The same thing happens for the upload drawer fields:

https://github.com/payloadcms/payload/assets/70709113/bc05fa58-2c9b-4d1d-94d2-a724ec80b6a2

  • [X] I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • [ ] Chore (non-breaking change which does not add functionality)
  • [X] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Change to the templates directory (does not affect core functionality)
  • [ ] Change to the examples directory (does not affect core functionality)
  • [ ] This change requires a documentation update

Checklist:

  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] Existing test suite passes locally with my changes
  • [ ] I have made corresponding changes to the documentation

AlessioGr avatar Dec 09 '23 16:12 AlessioGr