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 1 commit into from Jan 8, 2018


None yet
1 participant

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 Blocks label Jan 5, 2018

@aduth aduth merged commit b4fc426 into master Jan 8, 2018

3 checks passed

codecov/project 39.85% (+0%) compared to 255fe64
continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@aduth aduth deleted the fix/align-unset branch Jan 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment