-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Added 'clearEvent' to eventBus to prevent multiple attach event on wysiwyg editor #25671
Conversation
Hi @Nazar65. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
@@ -373,7 +373,7 @@ define([ | |||
/** | |||
* @param {Object} o | |||
*/ | |||
openFileBrowser: function (o) { | |||
openFileBrowser: _.debounce(function (o) { |
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.
Hey, did you find out what is the reason that openFileBrowser
is called multiple times in the first place?
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.
Hi @krzksz yes, this caused by this lines
varienGlobalEvents.fireEvent('open_browser_callback', payload); |
this.eventBus.fireEvent('open_browser_callback', payload); |
Where the same event fires two times with the same object, but as I observed this event needs both, but on some pages, these events triggered different result, like on product edit page this will fire twice, and on category page once as expected
@@ -78,6 +78,8 @@ define([ | |||
} | |||
|
|||
tinyMCE3.init(this.getSettings(mode)); | |||
varienGlobalEvents.clearEventHandlers("open_browser_callback"); | |||
varienGlobalEvents.attachEventHandler("open_browser_callback", tinyMceEditors.get(this.id).openFileBrowser); |
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.
Please take a look at static tests as they expect single apostrophes to be used.
@@ -310,7 +310,9 @@ protected function _getPluginButtonsHtml($visible = true) | |||
if (isset($buttonOptions['style'])) { | |||
$configStyle = $buttonOptions['style']; | |||
} | |||
// phpcs:disable Magento2.Performance.ForeachArrayMerge | |||
$buttonOptions = array_merge($buttonOptions, ['style' => 'display:none;' . $configStyle]); |
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.
This could be reworked into $buttonOptions['style'] = 'display:none;' . $configStyle;
so we don't need to disable any checks, right?
Hi @sivaschenko, thank you for the review. |
✔️ QA passed |
…h event on wysiwyg editor #25671
Hi @Nazar65, thank you for your contribution! |
Description (*)
Fixed Issues (if relevant)
Manual testing scenarios (*)
set
console.log('openfileBrowser')
on 376 line inlib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
1.1 open browser dev tools
Expected result openfileBrowser appears one time on console dev tools when you open file bwroser
[Case2]
AbodeStock
Open Adobe Stock on product page in content tab
Expected result Adobe Stock button opens grid
Questions or comments
Contribution checklist (*)