-
-
Notifications
You must be signed in to change notification settings - Fork 724
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
[Orders Page] Fix Confirmation modals do not auto-close #13004
base: master
Are you sure you want to change the base?
[Orders Page] Fix Confirmation modals do not auto-close #13004
Conversation
- Execute the close method only when the current context modal is opened
// Only execute close if there is an open modal | ||
if (!document.querySelector("body").classList.contains('modal-open')) return; | ||
// Only execute close if the current modal is open | ||
if (!this.modalTarget.classList.contains('in')) return; |
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 close
function is executed whenever the modal:close
event is triggered.
On the Orders page, we have 3 confirmation modals e.g.
- Resend Confirmation
- Send Invoice Confirmation
- Cancel Order Confirmation
Consider the scenario where the Cancel Order Confirmation Modal is confirmed, then the modal:close
event triggers. This close
function gets triggered 3 times for each confirmation modal in sequential order (Resend Confirmation Modal -> Send Invoice Confirmation -> Cancel Order Confirmation) as each is listening for this event.
On the first close
execution (for Resend Confirmation Modal), the modal-open
class is removed from the body as per Line#20.
So, on further executions (for Send Invoice Confirmation and Cancel Order Confirmation), the existing guard condition would always be true
, causing the method to return without any close operation. Further to this point, no other confirmation modal will be closed on the page.
So, updating the guard condition such that the close
function only triggers if the current modal is opened.
I hope this explanation makes sense, please let me know if I'm missing something.
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.
Great, it looks like a good change, because it's working more directly on the element associated with the controller, instead of accessing the global context which is generally a bad idea.
@@ -36,6 +37,7 @@ export default class extends Flatpickr { | |||
sv: sv, | |||
tr: tr, | |||
en: en, | |||
hu: hu, |
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.
Fixes the flatpickr invalid locale hu
error as mentioned in the issue
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.
Good work.
I think this would be worth mentioning on this page: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Internationalisation-%28i18n%29
It would be a helpful tip for someone when they're adding a new language.
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.
Thank you!
The missing locale will probably happen again with new instances. But we don't want to add too many locales to the JS either. It increases the size and other instances don't need it. It would be great to have a more flexible solution where we set the locale on demand and load it from a CDN.
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.
Great work, and good support. When it's a simple fix it's great to act straight away 👍
// Only execute close if there is an open modal | ||
if (!document.querySelector("body").classList.contains('modal-open')) return; | ||
// Only execute close if the current modal is open | ||
if (!this.modalTarget.classList.contains('in')) return; |
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.
Great, it looks like a good change, because it's working more directly on the element associated with the controller, instead of accessing the global context which is generally a bad idea.
@@ -36,6 +37,7 @@ export default class extends Flatpickr { | |||
sv: sv, | |||
tr: tr, | |||
en: en, | |||
hu: hu, |
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.
Good work.
I think this would be worth mentioning on this page: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Internationalisation-%28i18n%29
It would be a helpful tip for someone when they're adding a new language.
Yes Maikel, I strongly agree with this. Maybe in the future, we could incorporate it. |
Sure, David, let me add that. Thanks. |
David, It's added in the documentation here now. |
What? Why?
flatpickr invalid locale hu error
as mentioned in the issueWhat should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):