gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Custom classes do not get added to markup in editor for certain blocks

Open jvisick opened this issue 8 years ago • 1 comments

Issue Overview

Not every block that supports custom classes adds the class name to the block's markup while editing.

Most blocks that support custom classes add the entered classes to the block markup in the editor. This is great. You can add your custom defined styles and they immediately get reflected in Gutenberg while you are editing. However some blocks only add the custom class when viewed on the front-end and not while in the editor. This is a broken experience. I think a fix should be made to any block that supports custom classes to actually render the classes in edit mode.

I've gone through all the core blocks that support custom classes and the following don't add the custom class while editing:

  • Heading
  • Paragraph
  • List
  • Audio
  • Video
  • Embeds

Steps to Reproduce (for bugs)

  1. Create a new Heading, Paragraph, List, Audio, Video, or Embed block.
  2. While new block is active, select the block tab from the inspector.
  3. Add a custom class in the 'Additional CSS Class' input field.
  4. Check for class to be added to block markup using browser inspector tools.

Expected Behavior

Editing custom class is added to block while editing, allowing to see custom styles applied in editor.

Current Behavior

Editing custom classes for certain blocks does not get added to block while editing, it only show on the front end.

Possible Solution

Make sure the className property is added to the output of the edit function for any block that supports custom classes.

Screenshots / Video

Current: image

Fixed: image

Related Issues and/or PRs

I've put in a PR #5488 to fix heading, paragraph, list, and embeds. I am not quite sure how to fix the audio and video blocks?

Todos

  • [ ] Patch
  • [ ] Tests
  • [ ] Documentation

jvisick avatar Mar 07 '18 23:03 jvisick

#5488 addressed this issue. Related issues with server side rendered blocks (Latest Posts, Categories) are brought up in #5644

jvisick avatar Mar 15 '18 23:03 jvisick