e-commerce icon indicating copy to clipboard operation
e-commerce copied to clipboard

[14.0][IMP] ajaxify cart _onClickAdd return resolved promise

Open FrancescoBallerini opened this issue 1 year ago • 2 comments

(superseeds https://github.com/OCA/e-commerce/pull/903)

I wasn't sure about proposing this PR because this is not reproducible in runbot but it should be an improvement and in my case a valuable bug fixing, but I couldn't figure out the whole process behind this so I'd really like to see what you think.

Basically when I install website_sale_ajaxify_cart and activate the feature, I click on "Add to cart" and the _onClickAdd event is correctly executed once, but after the first execution two classes will be added to the button:

  • o_website_btn_loading
  • disabled

causing the button to stay forever in a disabled state like in screenshot (until I refresh the page ) image

These classes are really only added/remove by the execution of makeButtonHandler method which is used for async event handlers (_onClickAdd is async)

The issue here might be that if you don't resolve the pending promise you don't notify that the handler has done it's job, as reported here (makeAsyncHandler is the function calling makeButtonHandler). This is not an issue if you switch to cart page like in the original Odoo workflow, but it could cause issues with "ajaxify workflow" I guess.

My main doubt about this analysis is why the non-resolved Promise is not causing the same issue on runbot.

The refactoring I have introduced in this commit has solved the issue for me, I don't think that resolving Promise has any drawback in this situation, what do you think?

Does anyone ever had similar issues ?

FrancescoBallerini avatar Mar 03 '24 18:03 FrancescoBallerini

Hi @CetmixGitDrone, @geomer198, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar Mar 03 '24 18:03 OCA-git-bot

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar Aug 25 '24 12:08 github-actions[bot]