- Issue created by @bkosborne
- Open on Drupal.org βCore: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7last update
7 months ago Waiting for branch to pass - Status changed to Needs review
7 months ago 5:14pm 22 May 2024 - π³π±Netherlands johnv
Thanks, I was aware that there was some technical debt/errors in the code.
I will need to process the patch bit by bit, to check what has changed, and learn from it. - π³π±Netherlands johnv
When code is reviewed, there are comments about unnamed functions, so I will keep the function name in
attach: function doUpdateElement(context) {
- Status changed to Needs work
7 months ago 11:42am 28 May 2024 - π³π±Netherlands johnv
I went through all changes, and understood and copied all but one:
The following patch is still pending, since adding it breaks the following scenario (testing with dev-version):
- enable Exceptions in field settings, using the correct Widget.
- Push the 'Add exception' button. Then an element is rebuilt by a Ajax call. after that, the JS-links are broken.
- You may still add an exception and save the node.
- Now reopen the node, and see that without pressing 'Add exception', the exception's JS-links are fine, but broken after pressing the button.Thanks for your work!
diff --git a/js/office_hours.js b/js/office_hours.js index b25721f..07a596a 100644 --- a/js/office_hours.js +++ b/js/office_hours.js @@ -203,7 +203,7 @@ Drupal.behaviors.office_hours = { attach: function doUpdateElement(context) { - $(document).ready(function prepareElements() { + $(once('office-hours', '.field--type-office-hours', context)).each(function prepareElements() { // Attach a function to each JS link and initialize if needed. // N.B.: using * wildcard, since initially, no suffix is added, // but after 'Add exception'button, a suffix is added to the ID.
- π³π±Netherlands johnv
The past commit contains similar changes to js/office_hours_status_update.js.
Please check that file. - π³π±Netherlands johnv
I added the 'data-drupal-selector' to the code in π Use not-randomized drupal-data-selector, not #id Fixed and I credited you for that.
- First commit to issue fork.
- π§πͺBelgium andreasderijcke Antwerpen / Gent
After merge of the changes made up until 1.19, there was not much left but swapping out the
$(document).ready
with the once().That, also seems to fix π Additional slot row disappears after value change when used in nested paragraphs Needs work . I tested with a field in
- Tabs
- Details
- A Paragraph
- A Paragraph in Details
- Status changed to Needs review
3 months ago 4:08pm 20 September 2024 - Status changed to Needs work
3 months ago 4:15pm 20 September 2024 - π§πͺBelgium andreasderijcke Antwerpen / Gent
I forgot the exception case, that is still broken.
- Assigned to andreasderijcke
- Status changed to Active
3 months ago 5:29pm 20 September 2024 - Issue was unassigned.
- Status changed to Needs review
3 months ago 7:25pm 20 September 2024 - π§πͺBelgium andreasderijcke Antwerpen / Gent
I've updated the script to
- Apply all the initialisation and event handler binding per slot/row instead of the entire table at once. This makes sure new rows added by Ajax get the required processing. The 'once' at field level was blocking this.
- The striping fix was kept at field level, but it just occurs to me that I didn't check if that needs to be rerun after an exception is added, or when using the list widget.
Also
if ($nextTr.is(':hidden')) {
didn't work anymore for some reason, so I changed it to
if ($nextTr.hasClass('js-office-hours-hide')) {
which seems to have the same effect as far as I can tell. - π§πͺBelgium andreasderijcke Antwerpen / Gent
I've updated the script to
- Apply all the initialisation and event handler binding per slot/row instead of the entire table at once. This makes sure new rows added by Ajax get the required processing. The 'once' at field level was blocking this.
- The striping fix was kept at field level, but it just occurs to me that I didn't check if that needs to be rerun after an exception is added, or when using the list widget.
Also
if ($nextTr.is(':hidden')) {
didn't work anymore for some reason, so I changed it to
if ($nextTr.hasClass('js-office-hours-hide')) {
which seems to have the same effect as far as I can tell. - π³π±Netherlands johnv
Thanks a lot. The fix seems to address the problem. Committed.
Automatically closed - issue fixed for 2 weeks with no activity.