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

Block editor save results in validation error after changing attributes #6

Closed
afragen opened this issue Dec 16, 2018 · 11 comments
Closed

Comments

@afragen
Copy link
Owner

afragen commented Dec 16, 2018

@akirk It seems that adjusting the blocks frame size causes the block editor to add a surrounding <figure> tag to the iframe that contains the changed height or width. In this was only in the iframe.

This causes an invalid content error when trying to edit the post again.

screenshot_01

screenshot_04

Any ideas on how to fix this?

@afragen
Copy link
Owner Author

afragen commented Dec 16, 2018

Also notice the undefined__content-wrapper in the opening tag. It seems className is undefined.

<figure className={`${className}__content-wrapper`}>

@afragen
Copy link
Owner Author

afragen commented Dec 16, 2018

I think this is related. WordPress/gutenberg#10444

@afragen
Copy link
Owner Author

afragen commented Dec 16, 2018

The console log in Firefox is showing the Block validation error as expecting to see the default height/width but actually seeing the changed height/width.

@afragen afragen changed the title Block editor adding surrounding figure tag to adjusted frame size Block editor save results in validation error after changing attributes Dec 16, 2018
@afragen
Copy link
Owner Author

afragen commented Dec 17, 2018

I did a bunch more digging, at least as much as I could.

It seems that in the renderEdit attr is correctly saving all the data. I don't know what Update does with that data.

The issue seems to be in renderEmbed that none of the saved attributes are brought into that function. This means that renderEmbed only ever sees default data.

The align seems to save and it passed to renderEmbed

When renderEdit calls renderEmbed all the parameters are passed. When renderEmbed is called outside of renderEdit only the default parameters and align are passed.

I hope some of this makes sense.

@afragen
Copy link
Owner Author

afragen commented Dec 17, 2018

Also, no saved/changed data, except the alignment, survives a page reload.

@akirk
Copy link
Contributor

akirk commented Dec 17, 2018

Happy to take a look in the course of the week, aligning the generated HTML with the loading can be tricky. Thanks for the details, that helps me understand what you've already tried.

@afragen
Copy link
Owner Author

afragen commented Dec 18, 2018

Also it seems adding a PDF via URL doesn’t save.

@afragen
Copy link
Owner Author

afragen commented Dec 18, 2018

Perhaps this change. I haven’t tested.

return function (value) {
const attr = {};
attr[key] = value;
setAttributes(attr);
}

to

setAttributes( { key: value } );

This because setting a PDF from a media item which saves in JSON format works. Just brainstorming as saving an array seems to be problematic but saving it as JSON seems to work elsewhere.

@afragen
Copy link
Owner Author

afragen commented Dec 18, 2018

Well the above wasn't it.

I think there's something in renderEmbed that isn't saving the attributes. Everything in the editor seems to work but never transfers over to a page reload in the editor.

@afragen
Copy link
Owner Author

afragen commented Dec 19, 2018

@akirk So the issue seemed to be that an attribute of type number was not being stored but when changing to type string it was being stored. Both width and height were of type number, now they are working as type string   🤷‍♂️

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

No branches or pull requests

2 participants