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

Quote Block: Fix serializing the quote block #583

Merged
merged 1 commit into from
May 1, 2017
Merged

Conversation

youknowriad
Copy link
Contributor

closes #564

Follow the steps in #564 and ensures that the block is not empty anymore.

@youknowriad youknowriad added [Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended labels May 1, 2017
@youknowriad youknowriad self-assigned this May 1, 2017
@jasmussen
Copy link
Contributor

Can confirm that it fixes the problem for me! 👍

@youknowriad youknowriad merged commit bbcb450 into master May 1, 2017
@youknowriad youknowriad deleted the fix/quote-save branch May 1, 2017 10:51
const { value, citation, style = 1 } = attributes;

return (
<blockquote className={ `blocks-quote-style-${ style }` }>
{ value && value.map( ( paragraph, i ) => (
{ value && wp.element.Children.map( value, ( paragraph, i ) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the value attributes definition, we should be certain that value is an array, not one of React's opaque children structure:

query( 'blockquote > p', children() )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not when we insert an empty quote block, if we type inside the editable it'll not produce an array if we have a single paragraph.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not when we insert an empty quote block, if we type inside the editable it'll not produce an array if we have a single paragraph.

That's true, but in that case we have a bit of a mismatch between the shape of state on parse, and the value that will be assigned from Editable as described in your example.

Specifically, parse will treat a single paragraph as [ <p>foo</p> ], whereas in a new block, the same content would be assigned as just <p>foo</p>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really concerning? we could update the onChange callback to match this if you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, maybe not. Definitely want to avoid a situation where a developer would need to account for varying shapes of the value, if it ever comes to that (Array.isArray checks, React.Children.map when we know it's just one element, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blockquote block empties after switching to text and back.
3 participants