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

Blocks: Fix unsetting block alignment flagging block as invalid #4333

Merged
merged 1 commit into from
Jan 8, 2018

Conversation

aduth
Copy link
Member

@aduth aduth commented Jan 5, 2018

This pull request seeks to resolve an issue where unsetting a block's alignment by clicking the currently selected value would cause the block to save as invalid.

Implementation notes:

A block with a defined attribute type will coerce its value to that type, except in the case that the value is undefined. A null value is therefore coerced since there may be cases where the developer wants to explicitly save an empty value into attributes. This is an issue for blocks using the alignment toolbar because previously the unset would set the alignment value to null, which would be coerced to the string type as "null" (later serializing as <p style="text-align: null;"></span>. The changes here respect this behavior, passing undefined as the unset value when toggling the already-active alignment.

Testing instructions:

Verify that upon toggling a block's alignment on and off, saving the post, and reloading the editor, the block appears as valid:

  1. Navigate to Posts > New Post
  2. Insert a new Paragraph block
  3. Press Align Center in the block toolbar to toggle center alignment
  4. Press Align Center in the block toolbar to unset alignment
  5. Save the post
  6. Refresh the page

@aduth aduth added the [Feature] Blocks Overall functionality of blocks label Jan 5, 2018
@aduth aduth merged commit b4fc426 into master Jan 8, 2018
@aduth aduth deleted the fix/align-unset branch January 8, 2018 22:57
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant