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

Use vanilla JS to avoid issues because of jquery versions #96

Merged
merged 3 commits into from
Sep 21, 2020
Merged

Use vanilla JS to avoid issues because of jquery versions #96

merged 3 commits into from
Sep 21, 2020

Conversation

Nakahiru
Copy link
Contributor

@Nakahiru Nakahiru commented Aug 7, 2020

Questions Answers
Description? Use vanilla JS to avoid issues because of jquery versions
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes all issues listed in https://github.com/PrestaShopCorp/psgdpr/issues/103 when used in combination with PrestaShop/PrestaShop#20628 PR on Core
How to test? See the scenario described in PrestaShop/PrestaShop#20605

@Nakahiru Nakahiru added the bug Something isn't working label Aug 7, 2020
@matks
Copy link
Contributor

matks commented Aug 7, 2020

@V4LUX

because there is no selector that we can use to select it and hide it
This is something that we need to fix on the Core 🤔 if you needed this selector, other people might need it.

In theory we should provide IDs for all possible "items a module might want to select", right ? (if you have a small list, it would be awesome !)

@Nakahiru
Copy link
Contributor Author

Nakahiru commented Aug 7, 2020

@matks Yes but I think it is a bad practise to do what we have done for the past version. We should never execute some js stuff based on the Dom, no ? For x reasons if the Dom changed the js will not work anymore.

@matks
Copy link
Contributor

matks commented Aug 7, 2020

@matks Yes but I think it is a bad practise to do what we have done for the past version. We should never execute some js stuff based on the Dom, no ? For x reasons if the Dom changed the js will not work anymore.

In theory we try not to introduce BC breaks in the DOM because we know modules rely on it 😄 . For migration to Symfony it cannot be avoided, too much changes are happening. But we try to maintain upward compatibility for selectors.

What replacement do you use for selectors ? If you dont use selectors, what else do you use ?

@Nakahiru
Copy link
Contributor Author

Nakahiru commented Aug 7, 2020

Ok ok good to know. In this case, we do not use any kind of replacement. We decided to not hide addresses. We choose to do that in the past to avoid some potentially SAV. The rgpd module cannot delete these content from the database because it is used for accountancy purposes. Rgpd law allow to keep some data in this case.

@Nakahiru
Copy link
Contributor Author

Nakahiru commented Aug 7, 2020

Otherwise, the module used these two selectors before: #addressShipping and #addressInvoice. These two selector are now missing on 1.7.7.

@Nakahiru Nakahiru self-assigned this Aug 7, 2020
@matks
Copy link
Contributor

matks commented Aug 7, 2020

With PrestaShop/PrestaShop#20628 the missing selectors are back 🎉

addressInvoice.empty();
addressInvoice.append('<p>'+psgdprNoAddresses+'</p>');
addressInvoice.css("visibility", "visible");
document.addEventListener('DOMContentLoaded', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using $(document).on('ready')

Most browsers provide similar functionality in the form of a DOMContentLoaded event. However, jQuery's .ready() method differs in an important and useful way: If the DOM becomes ready and the browser fires DOMContentLoaded before the code calls .ready( handler ), the function handler will still be executed. In contrast, a DOMContentLoaded event listener added after the event fires is never executed.

from the jQuery doc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @V4LUX wanted to avoid using jQuery.
He did it because the current code does not work well with 1.7.7, and the bug comes from our update of jQuery version.

Since psgdpr module is supposed to work on multiple PS 1.7 versions, I think he chose a "no jQuery" solution to make sure it works on all PS versions.

@Darmona
Copy link

Darmona commented Aug 21, 2020

To sum up :
Are we reintroducing selectors then this PR is not useful anymore or do we merge @V4LUX 's PR ?
Team Core, are you still considering this as a blocking point for 1.7.7 ?

@matks
Copy link
Contributor

matks commented Aug 21, 2020

To sum up :
Are we reintroducing selectors then this PR is not useful anymore or do we merge @V4LUX 's PR ?

Hi, while exploring the issue with @V4LUX we actually identified 2 issues:

  1. First issue: the "shipping" and "delivery" adresses are not hidden by GDPR module because of missing selectors
  2. If the selectors are restored, the "shipping" and "delivery" adresses are hidden but there is a 2nd bug which prevents the information message to be displayed

The information message:

Team Core, are you still considering this as a blocking point for 1.7.7 ?

Yes it's blocking.

Issue 1 has been adressed on the Core in PR PrestaShop/PrestaShop#20628. The PR restores the missing selectors => the adresses are hidden.
Issue 2 is adressed by @V4LUX PR, this one. The PR fixes a jQuery compatibility issue => the information message is displayed.

So we need the 2 PRs to be validated. The most important PR is the one on the Core because by hiding the adresses, we comply with GDPR rules, but the 2nd PR is useful too 😅

@ngodefroy
Copy link

I tested on my mac, installed everything correctly with @sarahdib and found an error in console + the GPDR info not displayed:
Capture d’écran 2020-08-24 à 12 42 18

On Sarah's laptop, we were able to test:
The addresses for shipping and billing are hidden, even if the client did not specified it. => KO
No errors found in console =>OK

I also wonder if we shouldn't have only one time the message about GDPR? even thought it hides two things.
or maybe indicating in the GDPR message, which part is hidden?
Capture d’écran 2020-08-24 à 12 06 46

@matks matks changed the title Avoid to hide invoice and delivery address on 1.7.7 Use vanilla JS to avoid issues because of jquery versions Sep 21, 2020
@SD1982
Copy link

SD1982 commented Sep 21, 2020

LGTM Thanks @V4LUX !!

@matks matks merged commit 1a7ccd5 into PrestaShop:dev Sep 21, 2020
@matks matks mentioned this pull request Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QA ✔️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants