From 065b26c76c161a07e49a532ffb8dd900485124b6 Mon Sep 17 00:00:00 2001 From: Nikolay Ninarski Date: Wed, 30 Jan 2019 14:21:46 +0200 Subject: [PATCH] Removed unnecessary className attribute. Fixes #11664 (#11831) ## Description Added a check for empty string to the `onChange` handler of the "Additional CSS Class field". If the string is empty the `setAttributes` is called with `{ className: undefined }` This will resolve #11664 ## How has this been tested? Created a new post and added a heading block. In the Advanced menu, added a class and switched to the Code Editor Tested on local WP running on Windows with Chrome 70.0.3538.102 ## Types of changes Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] My code is tested. - [x] My code follows the WordPress code style. - [x] My code follows the accessibility standards. - [x] My code has proper inline documentation. --- packages/editor/src/hooks/custom-class-name.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor/src/hooks/custom-class-name.js b/packages/editor/src/hooks/custom-class-name.js index 9779dfd1a2bb5..3d4af47227670 100644 --- a/packages/editor/src/hooks/custom-class-name.js +++ b/packages/editor/src/hooks/custom-class-name.js @@ -65,7 +65,7 @@ export const withInspectorControl = createHigherOrderComponent( ( BlockEdit ) => value={ props.attributes.className || '' } onChange={ ( nextValue ) => { props.setAttributes( { - className: nextValue, + className: nextValue !== '' ? nextValue : undefined, } ); } } />