-
Notifications
You must be signed in to change notification settings - Fork 2k
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
editor tracks - fix replace blocks flow not triggering insert event #54415
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/6166903 Thank you @Addison-Stavlo for including a screenshot in the description! This is really helpful for our translators. |
ignoreNextReplaceBlocksAction = true; | ||
( mapping, event, target ) => { | ||
const item = target.querySelector( '.components-menu-item__item' ); | ||
if ( item?.innerText === __( 'Detach blocks from template part' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Automattic/i18n will this work, matching a translated string from Core? ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@creativecoder, Seems like it's using the global @wordpress/i18n
instance in the same context as the block editor, so they are sharing the same locale data and the results of the __
translate call in the menu item and in the condition should be matching.
Translation for this Pull Request has now been finished. |
Changes proposed in this Pull Request
Cleans up a bug introduced in #53592.
In the above PR, an event was tracked via a selector but had extra conditions used to determine the proper context if the event should fire:
wp-calypso/apps/wpcom-block-editor/src/wpcom/features/tracking/wpcom-block-editor-template-part-detach-blocks.js
Lines 24 to 25 in f7b5d6d
A subscriber was also added to this event, but its function did not contain the same extra conditions to determine proper context as the original event. Therefore other actions taking place that match this selector (
'.components-menu-item__button'
such as replacing a block's type via the block toolbar), are unintentionally triggering the subscriber function for the event. Here we have added the extra conditions to the subscriber function to prevent it from firing in the wrong circumstances.Testing instructions
Related to #53410