Skip to content

Commit f40cef1

Browse files
Arukuenbfintal
andauthored
fix (posts): update selectors for image styles to work (#3535)
* fix(posts): also return original selectors to avoid overwriting * Update src/block/posts/style.js --------- Co-authored-by: Benjamin Intal <[email protected]>
1 parent aaae28b commit f40cef1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/block/posts/style.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,18 @@ Image.addStyles( blockStyles, {
294294
}
295295
return true
296296
},
297-
selectorCallback: getAttribute => {
297+
selectorCallback: ( getAttribute, _attributes, _clientId, props ) => {
298298
const className = getAttribute( 'className' )
299299
const blockStyle = getBlockStyle( variations, className )
300300
const imageHasLink = getAttribute( 'imageHasLink' )
301301

302+
const selector = props.selector
302303
if ( [ 'list' ].includes( blockStyle?.name ) && imageHasLink ) {
303-
return `${ itemSelector } .stk-block-posts__image-link`
304+
return Array.isArray( selector )
305+
? [ ...selector, `${ itemSelector } .stk-block-posts__image-link` ]
306+
: [ selector, `${ itemSelector } .stk-block-posts__image-link` ]
304307
}
305-
return '.stk-img-wrapper'
308+
return selector
306309
},
307310
widthStyleRuleCallback: getAttribute => {
308311
const className = getAttribute( 'className' )

src/components/block-css/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ const BlockCss = props => {
288288
}
289289
const hoverStyleRule = _hoverStyleRule || styleRule
290290

291-
let selector = selectorCallback ? selectorCallback( getAttribute, attributes, clientId ) : _selector
291+
let selector = selectorCallback ? selectorCallback( getAttribute, attributes, clientId, props ) : _selector
292292
let hoverSelector = hoverSelectorCallback ? hoverSelectorCallback( getAttribute, attributes, clientId ) : _hoverSelector
293293

294294
const desktopQuery = ( Array.isArray( responsive ) ? responsive.find( s => s.startsWith( 'desktop' ) ) : 'desktop' ) || 'desktop'

0 commit comments

Comments
 (0)