-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Auto-save performed when manipulating a footnotes block breaks attributes in other blocks. #53212
Comments
@celtislab could you please provide clear, step-by-step reproduction instructions and a description of what the unexpected behaviour is? |
Only the array of strings and the corresponding function are extracted for reproduction.
If you do this, it will be called recursively since it is an array. The "1024x768" string is set as an attribute on recursive calls However, key becomes undefined and is treated as an object instead of a string, and the converted value is stored as {0: "1", 1: "0", 2: "2", 3: "4", 4: "x", 5: "7", 6: "6", 7: "8"}. Therefore, if key is undefined, it is likely to need to be handled so that it is not mistakenly converted to an object type. |
@celtislab just wanted to confirm the issue here. So you have a custom attribute that is an array of strings. Given the changes made to handle Footnotes, now, when the attributes are updated, the strings in the array are converted into objects. Is that correct? |
That's right. |
Thanks for reporting this one! I can reproduce too, using a custom block created via using In
Then, in the block's
The expected result: Here's what happens if we add a Paragraph block to the post alongside the custom block, and attempt to add a footnote: 2023-08-02.15.11.55.mp4From the looks of it, I think we might need some checks at the beginning of |
Potential fix up over in #53257 |
Description
In function updateAttributes(attributes) in const updateFootnotes called in the footnote block,
Recursive calls to the updateAttributes function
If there is an attribute of an array of strings at this time
For example, the string "1024x768" is converted to {0: "1", 1: "0", 2: "2", 3: "4", 4: "x", 5: "7", 6: "6", 7: "8"} and an error occurs
Step-by-step reproduction instructions
This happens when you manipulate the footnote block in the editor.
This happens in blocks that use an array of strings in the attributes, but does not seem to be used in the core block.
Screenshots, screen recording, code snippet
Environment info
WordPress 6.3 RC2
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: