Skip to content

Commit 2cc7011

Browse files
Arukuenbfintal
andauthored
fix: wp7 compatibility (#19)
* fix: proper use of ToggleControl * fix: UI fixes * fix: safely remove type prop * fix: proper css scope * Apply suggestion from @bfintal --------- Co-authored-by: Benjamin Intal <bfintal@gmail.com>
1 parent cec35db commit 2cc7011

6 files changed

Lines changed: 41 additions & 4 deletions

File tree

src/editor/components/add-interaction-popover/editor.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@ h4.components-menu-group__label {
8383
.interface-interface-skeleton__header:has(.interact-add-interaction-popover) {
8484
z-index: 99 !important;
8585
}
86+
87+
.interact-add-interaction-popover .components-toggle-group-control {
88+
height: auto;
89+
}

src/editor/components/interaction-panel/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ const InteractionPanel = props => {
390390
{ interactionConfig.options.map( option => {
391391
const { type, condition } = option
392392
const propsToPass = {}
393+
const optionToPass = { ...option }
393394

394395
const Tag = type === 'number' ? NumberControl
395396
: type === 'select' ? SelectControl
@@ -402,6 +403,9 @@ const InteractionPanel = props => {
402403
} else { // Default value
403404
propsToPass.checked = option.placeholder || false
404405
}
406+
// Wordpress 7.0 Compatibility
407+
// ToggleControl is messed up in Wordpress 7.0 when type prop is added.
408+
delete optionToPass.type
405409
}
406410

407411
// Conditionally display the option.
@@ -416,7 +420,7 @@ const InteractionPanel = props => {
416420

417421
return (
418422
<Tag
419-
{ ...option }
423+
{ ...optionToPass }
420424
key={ option.name }
421425
value={ editedInteraction.options?.[ option.name ] || '' }
422426
onChange={ value => {

src/editor/components/target-selector/editor.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,10 @@
6969
}
7070
}
7171
}
72+
73+
/* Wordpress 7.0 compatibility */
74+
75+
// Text control losses its margin bottom.
76+
.interact-target-block-input .components-base-control__field {
77+
margin-bottom: 8px;
78+
}

src/editor/components/target-selector/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const TargetSelector = props => {
204204
<FlexLayout justifyContent="start">
205205
{ isHorizontal && targetButton }
206206
<TextControl
207+
className="interact-target-block-input"
207208
id="interact-target-block-input"
208209
label={ __( 'Block Anchor / ID', 'interactions' ) }
209210
value={ value.value }

src/editor/components/timeline/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,9 +1147,7 @@ const Timeline = props => {
11471147
return ! value
11481148
} )
11491149
} }
1150-
>
1151-
{ __( 'Live Preview', 'interactions' ) }
1152-
</ToggleControl>
1150+
/>
11531151
) }
11541152
</BaseControl>
11551153
)

src/editor/editor.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,26 @@
138138
.interact-add-interaction-button-wrapper {
139139
--wp-components-color-accent: #05f;
140140
}
141+
142+
/* Wordpress 7.0 compatibility */
143+
144+
.interact-sidebar, .interact-popover {
145+
// Toggle control loses its margin bottom.
146+
.components-toggle-control {
147+
margin-bottom: 12px;
148+
}
149+
150+
// Text control min-height changed from 30px to 40px.
151+
.components-text-control__input {
152+
min-height: 30px !important;
153+
}
154+
155+
// Select control field loses its margin bottom.
156+
.components-select-control .components-base-control__field {
157+
margin-bottom: 8px;
158+
}
159+
160+
.interact-property-control .components-base-control__field {
161+
margin-bottom: 8px;
162+
}
163+
}

0 commit comments

Comments
 (0)