Skip to content

Commit 355b784

Browse files
authored
Merge pull request #974 from Kit/fix-block-keys
Blocks: Fix unique `key` prop warning
2 parents 9b22e1b + f4b5a0c commit 355b784

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

resources/backend/css/gutenberg.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.components-flex-item button.wp-convertkit-refresh-resources {
33
margin: 24px 0 0 0;
44
padding: 0;
5-
height: 32px;
5+
height: 40px;
66
}
77

88
.components-flex-item button.wp-convertkit-refresh-resources span.dashicons {

resources/backend/js/gutenberg-block-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function convertKitGutenbergFormBlockRenderPreview(block, props) {
7777
{
7878
className: className.join(' '),
7979
},
80-
wp.components.SandBox({
80+
wp.element.createElement(wp.components.SandBox, {
8181
html,
8282
title: block.name,
8383
styles: [

resources/backend/js/gutenberg.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ function convertKitGutenbergRegisterBlock(block) {
144144
label: field.label,
145145
help: field.description,
146146
value: props.attributes[attribute],
147+
148+
// Add __next40pxDefaultSize and __nextHasNoMarginBottom properties,
149+
// preventing deprecation notices in the block editor and opt in to the new styles
150+
// from 7.0.
151+
__next40pxDefaultSize: true,
152+
__nextHasNoMarginBottom: true,
153+
147154
onChange(value) {
148155
if (field.type === 'number') {
149156
// If value is a blank string i.e. no attribute value was provided,
@@ -229,10 +236,18 @@ function convertKitGutenbergRegisterBlock(block) {
229236
[
230237
el(
231238
FlexItem,
232-
{},
239+
{
240+
key: attribute + '-select',
241+
},
233242
el(SelectControl, fieldProperties)
234243
),
235-
el(FlexItem, {}, inlineRefreshButton(props)),
244+
el(
245+
FlexItem,
246+
{
247+
key: attribute + '-refresh',
248+
},
249+
inlineRefreshButton(props)
250+
),
236251
]
237252
);
238253

@@ -509,9 +524,15 @@ function convertKitGutenbergRegisterBlock(block) {
509524
} else {
510525
// Refresh button enabled; display the notice, link and button.
511526
elements = [
512-
!block.has_access_token
513-
? block.no_access_token.notice
514-
: block.no_resources.notice,
527+
el(
528+
'div',
529+
{
530+
key: props.clientId + '-notice',
531+
},
532+
!block.has_access_token
533+
? block.no_access_token.notice
534+
: block.no_resources.notice
535+
),
515536
noticeLink(props, setButtonDisabled),
516537
refreshButton(props, buttonDisabled, setButtonDisabled),
517538
];

0 commit comments

Comments
 (0)