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

Unique field id (uuid) and block duplicates #104

Closed
1 of 4 tasks
eri-trabiccolo opened this issue Jun 1, 2021 · 5 comments
Closed
1 of 4 tasks

Unique field id (uuid) and block duplicates #104

eri-trabiccolo opened this issue Jun 1, 2021 · 5 comments
Assignees
Labels

Comments

@eri-trabiccolo
Copy link
Contributor

Reproduction Steps

  • Edit a form and create a field (it'll be assigned an unique id)
  • Duplicate
  • check the code editor

similarly

  • create a field in a form, and make it reusable
  • in another form add the reusable block just created
  • turn it into a normal block
  • check the code editor of both the form's field and the reusable block's field

Expected Behavior

  • I'd expect the two fields to have different uuid

Actual Behavior

  • The two fields have the same uuid

Error Messages / Logs

n/a

System and Environment Information

head at dafd798

This issue has be recreated:

  • Locally
  • On a staging site
  • On a production website
  • With only LifterLMS and a default theme

Browser, Device, and Operating System Information

n/a

@eri-trabiccolo eri-trabiccolo added Type: Bug Bugs and errors Type: Enhancement Improvements existing features or code Severity: Normal labels Jun 1, 2021
@thomasplevy thomasplevy removed the Type: Enhancement Improvements existing features or code label Jun 1, 2021
@thomasplevy
Copy link
Contributor

Other values which should be unique are affected by this issue as well: name, data_store_key, etc...

Also the steps above can be reduced to:

  1. Create a field
  2. Duplicate the field
  3. Observe the UUID (or other attribute) of the new field is the same as the source field

@thomasplevy thomasplevy self-assigned this Jun 2, 2021
@thomasplevy
Copy link
Contributor

Plan:

when a field block is added to the editor, it's data must be pushed into the the window.llms.userInfoFields array so that validation can take place immediately against it's data

im not sure how to delete the item from the array when a block is removed that was created before being saved

when duplicating / copying a field we should determine if it was a copy by checking against window.llms.userInfoFields to see if the name already exists, if it does we'll clear the id, name, uuid and data_store_key before passing to setupAtts() so that new values can be created immediately

@eri-trabiccolo
Copy link
Contributor Author

@thomasplevy I wonder if there's an easy way to just disable the duplicate button for our blocks... until we find a more stable solution.

@thomasplevy
Copy link
Contributor

I can't find a way to disable the duplication functionality and then there's also the "copy" functionality too (also can't figure out how to disable).

I also can't figure out how to solve this according to my plan. Good stuff.

@thomasplevy
Copy link
Contributor

It's feeling pretty close to impossible to "solve" this and part of the reason seems to be that we're leveraging block attributes in a way that they aren't intended to be used... surprised? I'm kind of not...

Saving this here for reference: WordPress/gutenberg#23377

I have written code to determine whether or not a block is a "duplicate" and, if it is, it unsets the properties that should be unique so they'll be regenerated, however it's happening in the wrong order and the source block (the block which was used to duplicate from) shows up as a duplicate first and the later block (the duplicate) ends up with the original block's properties.

I need to revisit this approach to see if I can make it happen to the actual duplicate block.

@thomasplevy thomasplevy mentioned this issue Jun 9, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants