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

Edit EMA: 🐛 Custom Event select-contentlet is triggering twice on ng-contentlet-selector #26958

Closed
Tracked by #26644
zJaaal opened this issue Dec 11, 2023 · 0 comments · Fixed by #27363
Closed
Tracked by #26644

Comments

@zJaaal
Copy link
Contributor

zJaaal commented Dec 11, 2023

Parent Issue

#26644

Problem Statement

When selecting a contentlet on contentlet selector, the event is triggering twice, resulting in a double request that ends in an error while saving the new content of the page.

Steps to Reproduce

  1. Go to http://localhost:8080/dotAdmin/#/edit-ema be sure that you have an instance of this project running with a valid token and also an active license.
  2. Click on the add contentlet button, you should see the ng-contentlet-selector dialog in your screen.
  3. Click on the select button of any contenlet. (Optional) If neeed delete all the contentlets until you get to step 4.
  4. The table should be empty and your console should have a bad request error (Repeat steps from 1 to 3, until you get here)

Screenshot of the error

Screenshot 2023-12-11 at 2 09 14 PM

Acceptance Criteria

  • We should be able to maintain the flow of work, right now the dialog just breaks and we need to reload the page to keep working.
  • The dialog should close and the content should be saved without errors.

dotCMS Version

master - latest

Proposed Objective

User Experience

Proposed Priority

Priority 3 - Average

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

We made some research about this issue. We found out that this is related to the event of the select button being bubbled up to the row, that has the same event. So, it triggers twice, one for the select and one for the Row.

Both events are being handled here:

// Select button functionality
var selected = function (scope, content) {
if (this.useRelateContentOnSelect) {
scope._doRelateContent(content);
} else {
scope._onContentSelected(content);
}
};
if (this.multiple == 'false') {
var asset = cellData;
var selectRow = dojo.byId('rowId' + i);
if (selectRow.onclick == undefined) {
selectRow.onclick = dojo.hitch(
this,
selected,
this,
asset
);
}
}

if (this.multiple == 'false') {
for (var i = 0; i < data.length; i++) {
var asset = data[i];
var selectButton = dojo.byId(
this.searchCounter + asset.inode
);
if (selectButton.onclick == undefined) {
selectButton.onclick = dojo.hitch(
this,
selected,
this,
asset
);
}
}
}

And both handlers are using the method from here.

We don't have a fix at the moment, that's the reason of this ticket. We need to make further research to be sure of how are we going to solve this and to be sure that the fix should be made in one of those files.

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

@zJaaal zJaaal mentioned this issue Dec 11, 2023
@fmontes fmontes changed the title Edit EMA: Custom Event select-contentlet is triggering twice on ng-contentlet-selector Edit EMA: (BUG) Custom Event select-contentlet is triggering twice on ng-contentlet-selector Dec 20, 2023
@fmontes fmontes changed the title Edit EMA: (BUG) Custom Event select-contentlet is triggering twice on ng-contentlet-selector Edit EMA: 🐛 Custom Event select-contentlet is triggering twice on ng-contentlet-selector Dec 20, 2023
@KevinDavilaDotCMS KevinDavilaDotCMS self-assigned this Jan 18, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 18, 2024
…n ng-contentlet-selector #26958 (#27363)

* Fixed trigger twice on ng-contentlet-selector

* Modified ContentSelector.js. Revert changed on Angular app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment