Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (video popup): change button tag with div tag #3121

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/block/video-popup/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,36 @@ import { Save } from './save'
import { attributes } from './schema'

import { withVersion } from '~stackable/higher-order'
import { semverCompare } from '~stackable/util'
import { i18n } from 'stackable'
import {
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
deprecateBlockShadowColor, deprecateContainerShadowColor,
} from '~stackable/block-components'

/**
* WordPress dependencies
*/
import { InnerBlocks } from '@wordpress/block-editor'
import { addFilter } from '@wordpress/hooks'
import { __ } from '@wordpress/i18n'

addFilter( 'stackable.video-popup.save.div.content', 'stackable/3.12.14', ( output, props, contentClassNames ) => {
if ( semverCompare( props.version, '<', '3.12.14' ) ) {
return (
<button className={ contentClassNames } aria-label={ props.attributes.ariaLabel || __( 'Play Video', i18n ) }>
<InnerBlocks.Content />
</button>
)
}
return output
} )

const deprecated = [
{
attributes: attributes( '3.12.14' ),
save: withVersion( '3.12.14' )( Save ),
},
{
// Support the new shadow color.
attributes: attributes( '3.12.11' ),
Expand Down
3 changes: 2 additions & 1 deletion src/block/video-popup/frontend-video-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class StackableVideoPopup {
}
}
els.forEach( el => {
el.querySelector( 'button' ).addEventListener( 'click', ev => {
// We're now using divs, but keep the `button` selector for backward compatibility.
el.querySelector( 'div[role="button"], button' ).addEventListener( 'click', ev => {
ev.preventDefault()
openVideo( el )
} )
Expand Down
15 changes: 12 additions & 3 deletions src/block/video-popup/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
*/
import { InnerBlocks } from '@wordpress/block-editor'
import { compose } from '@wordpress/compose'
import { applyFilters } from '@wordpress/hooks'
import { __ } from '@wordpress/i18n'

export const Save = props => {
Expand Down Expand Up @@ -60,9 +61,17 @@ export const Save = props => {
>
<IconLabelStyles.Content version={ props.version } attributes={ attributes } />
<CustomCSS.Content attributes={ attributes } />
<button className={ contentClassNames } aria-label={ attributes.ariaLabel || __( 'Play Video', i18n ) }>
<InnerBlocks.Content />
</button>
{ applyFilters( 'stackable.video-popup.save.div.content', (
<div
className={ contentClassNames }
aria-label={ attributes.ariaLabel || __( 'Play Video', i18n ) }
tabIndex="0"
role="button"
>
<InnerBlocks.Content />
</div>
), props, contentClassNames ) }

</BlockDiv.Content>
)
}
Expand Down
Loading