Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85778

JS event sectionRefreshed is not dispatched when section visibility is changed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.5.6
    • Course, JavaScript
    • None
    • MOODLE_405_STABLE

      We're upgrading one of our custom plugins to 4.5 and noticed that sectionRefreshed custom JS event (core_course:sectionRefreshed) is not triggered anymore when the section visibility is changed on the course page. 
       
      Looks like dispatching sectionRefreshed event is missing in _reloadSection
       https://github.com/moodle/moodle/blob/main/course/format/amd/src/local/content.js#L662
       
      In our case our custom plugin adds extra HTML bits to the section. JS code looks like following
       

      document.querySelector(SELECTORS.PAGE).addEventListener(CourseEvents.sectionRefreshed, (event) => {
          if (event.detail.newSectionElement !== undefined) {
              event.detail.newSectionElement.querySelectorAll(SELECTORS.ACTIVITY_CHOOSER).forEach(element => {
                  initAddBentoBoxLink(element);
              });
          }
      }); 

      This works ok in Moodle 4.1

            Unassigned Unassigned
            dmitriim Dmitrii Metelkin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.