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

Added 'clearEvent' to eventBus to prevent multiple attach event on wysiwyg editor #25671

Merged
merged 8 commits into from
Nov 27, 2019

Conversation

Nazar65
Copy link
Member

@Nazar65 Nazar65 commented Nov 20, 2019

Description (*)

Fixed Issues (if relevant)

  1. Search Adobe Stock button is not active on Edit Product Page in Admin adobe-stock-integration#689

Manual testing scenarios (*)

set console.log('openfileBrowser') on 376 line in lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
1.1 open browser dev tools

  1. Open Catalog -> product -> Add new product
  2. Content Tab -> on wisiwyg editor press image icon -> source click folder button

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 (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@Nazar65 Nazar65 requested a review from DrewML as a code owner November 20, 2019 15:20
@m2-assistant
Copy link

m2-assistant bot commented Nov 20, 2019

Hi @Nazar65. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@Nazar65 Nazar65 changed the title Remove duplicated fireEcent, that prevents to duble initialization Remove duplicate fireEvent, to prevent double initialization Nov 20, 2019
@Nazar65 Nazar65 changed the title Remove duplicate fireEvent, to prevent double initialization Added debounce to 'open FIle Browser', to prevent double invocation at the same time Nov 21, 2019
@@ -373,7 +373,7 @@ define([
/**
* @param {Object} o
*/
openFileBrowser: function (o) {
openFileBrowser: _.debounce(function (o) {
Copy link
Contributor

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?

Copy link
Member Author

@Nazar65 Nazar65 Nov 21, 2019

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

@ghost ghost assigned krzksz Nov 21, 2019
@Nazar65 Nazar65 requested a review from YevSent as a code owner November 22, 2019 12:39
@Nazar65 Nazar65 changed the title Added debounce to 'open FIle Browser', to prevent double invocation at the same time Added 'clearEvent' to eventBus to prevent multiple attach event on wysiwyg editor Nov 22, 2019
@@ -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);
Copy link
Contributor

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]);
Copy link
Contributor

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?

@Nazar65 Nazar65 added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Nov 23, 2019
@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-6329 has been created to process this Pull Request

@engcom-Delta
Copy link
Contributor

✔️ QA passed

@engcom-Foxtrot engcom-Foxtrot self-assigned this Nov 26, 2019
magento-engcom-team pushed a commit that referenced this pull request Nov 27, 2019
@magento-engcom-team magento-engcom-team merged commit 7b16d76 into magento:2.3-develop Nov 27, 2019
@m2-assistant
Copy link

m2-assistant bot commented Nov 27, 2019

Hi @Nazar65, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.5 milestone Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants