Skip to content

Commit 99abbc0

Browse files
committed
fix(posts): also return original selectors to avoid overwriting
1 parent 9890d19 commit 99abbc0

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/block/posts/style.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,34 @@ Image.addStyles( blockStyles, {
294294
}
295295
return true
296296
},
297-
selectorCallback: getAttribute => {
297+
// selectorCallback: ( getAttribute, _attributes, _clientId, props ) => {
298+
// const className = getAttribute( 'className' )
299+
// const blockStyle = getBlockStyle( variations, className )
300+
// const imageHasLink = getAttribute( 'imageHasLink' )
301+
302+
// const selector = props.selector
303+
// if ( [ 'list' ].includes( blockStyle?.name ) && imageHasLink ) {
304+
// if ( Array.isArray( selector ) ) {
305+
// return selector.map( sel =>
306+
// sel.replace( '.stk-img-wrapper', `${ itemSelector } .stk-block-posts__image-link ` )
307+
// )
308+
// }
309+
// return [ '.stk-img-wrapper', selector.replace( '.stk-img-wrapper', `${ itemSelector } .stk-block-posts__image-link` ) ]
310+
// }
311+
// return selector
312+
// },
313+
selectorCallback: ( getAttribute, _attributes, _clientId, props ) => {
298314
const className = getAttribute( 'className' )
299315
const blockStyle = getBlockStyle( variations, className )
300316
const imageHasLink = getAttribute( 'imageHasLink' )
301317

318+
const selector = props.selector
302319
if ( [ 'list' ].includes( blockStyle?.name ) && imageHasLink ) {
303-
return `${ itemSelector } .stk-block-posts__image-link`
320+
return Array.isArray( selector )
321+
? [ ...selector, `${ itemSelector } .stk-block-posts__image-link` ]
322+
: [ selector, `${ itemSelector } .stk-block-posts__image-link` ]
304323
}
305-
return '.stk-img-wrapper'
324+
return selector
306325
},
307326
widthStyleRuleCallback: getAttribute => {
308327
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)