Skip to content

Commit

Permalink
Removed unnecessary className attribute. Fixes #11664 (#11831)
Browse files Browse the repository at this point in the history
## 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. <!-- Check code: `npm run lint`, Guidelines: https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/ -->
- [x] My code follows the accessibility standards. <!-- Guidelines: https://make.wordpress.org/core/handbook/best-practices/coding-standards/accessibility-coding-standards/ -->
- [x] My code has proper inline documentation. <!-- Guidelines: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/javascript/ -->
  • Loading branch information
ninio authored and youknowriad committed Mar 6, 2019
1 parent 5937b0d commit 065b26c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/editor/src/hooks/custom-class-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const withInspectorControl = createHigherOrderComponent( ( BlockEdit ) =>
value={ props.attributes.className || '' }
onChange={ ( nextValue ) => {
props.setAttributes( {
className: nextValue,
className: nextValue !== '' ? nextValue : undefined,
} );
} }
/>
Expand Down

0 comments on commit 065b26c

Please sign in to comment.