How to remove behaviors/actions associated with data-wp-on? #58643
daotw
started this conversation in
Interactivity API
Replies: 1 comment 6 replies
-
You can remove them in PHP using a add_filter( 'render_block_core/navigation', function( $content ){
$p = new WP_HTML_Tag_Processor ( $content );
if ( $p->next_tag( array( 'class_name' => 'wp-block-navigation-item' ) ) ) {
$p->remove_attribute( 'data-wp-on--mouseenter' );
$p->remove_attribute( 'data-wp-on--mouseleave' );
}
return $p->get_updated_html();
}); However, similar to what would happen with a |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
How to remove behaviors associated with
data-wp-on--mouseenter="actions.core.navigation.openMenuOnHover"
anddata-wp-on--mouseleave="actions.core.navigation.closeMenuOnHover"
?Snippet from one of my submenus:
<li data-wp-context="{ "core": { "navigation": { "submenuOpenedBy": {}, "type": "submenu" } } }" data-wp-effect="effects.core.navigation.initMenu" data-wp-interactive="" data-wp-on--focusout="actions.core.navigation.handleMenuFocusout" data-wp-on--keydown="actions.core.navigation.handleMenuKeydown" data-wp-on--mouseenter="actions.core.navigation.openMenuOnHover" data-wp-on--mouseleave="actions.core.navigation.closeMenuOnHover" tabindex="-1" class="wp-block-navigation-item has-child open-on-hover-click wp-block-navigation-submenu">...</li>
Interactivity API doc doesn't provide event name and reference function. I guessed
mouseenter
andopenMenuOnHover
, respectively, for usingremoveEventListener
, but they seem to be wrong.People may have the same question because Interactivity API doc doesn't provide the answer
A complete list of removing and adding "actions" reference guide is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions