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

Data Privacy use of core/modal_factory amd (triggerElement double event)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • None
    • 3.9.3, 3.10, 3.11, 4.0
    • JavaScript, Privacy
    • None
    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • MDL-70395-master
    • Hide

      Issue test

      1. Navigate to "Privacy and Polices" -> "Data registry" (admin/tool/dataprivacy/dataregistry.php) in site administration
      2. Click on + button near "Category", observe modal form is loaded.
      3. Click on cancel in the modal form.
      4. Repeat steps 2 and 3, make sure Category modal can be closed (modal window should disappear, focus is returned to + button).
      5. Click on + button near "Purpose", observe modal form is loaded.
      6. Click on cancel in the modal form.
      4. Repeat steps 5 and 6, make sure Purpose modal can be closed (modal window should disappear, focus is returned to + button).

      Regression test

      Same as above, but instead of clicking cancel in modal window at step 3 and 6, fill-in required fields and save, observe data was submitted (new category and purpose were added to the lists)

      Show
      Issue test 1. Navigate to "Privacy and Polices" -> "Data registry" ( admin/tool/dataprivacy/dataregistry.php ) in site administration 2. Click on + button near "Category", observe modal form is loaded. 3. Click on cancel in the modal form. 4. Repeat steps 2 and 3, make sure Category modal can be closed (modal window should disappear, focus is returned to + button). 5. Click on + button near "Purpose", observe modal form is loaded. 6. Click on cancel in the modal form. 4. Repeat steps 5 and 6, make sure Purpose modal can be closed (modal window should disappear, focus is returned to + button). Regression test Same as above, but instead of clicking cancel in modal window at step 3 and 6, fill-in required fields and save, observe data was submitted (new category and purpose were added to the lists)

      Data privacy add_category and add_purpose modules are using ModalFactory as follows:

                 trigger.on('click', function() {
                      return this.strings.then(function(strings) {
                          ModalFactory.create({
                              type: ModalFactory.types.SAVE_CANCEL,
                              title: strings[0],
                              body: '',
                          }, trigger).done(function(modal) {
                              this.setupFormModal(modal, strings[1]);
                          }.bind(this));
                      }.bind(this))
                      .fail(Notification.exception);
                  }.bind(this));
      

      This results in interesting scenario. First, on click, modal is created, but notice that trigger element passed as second param. ModalFactory is using it to hook up 'activate' event on it. So once modal is shown, suppose user clicks "cancel" - this destroys modal, but this new event hook remains in place. Clicking on trigger element again results in two modals opened one above the other, you can only close top one by clicking cancel, destory event does not seem attached to underlying one.

      While use of ModalFactory does not seem correct in this case (no need to pass trigger parameter like it used in many other places, unless you initialising it for partcular element action, not as result of action), this is not reproducable in 3.8. I can't see clearly where regression might came from.

            kabalin Ruslan Kabalin
            kabalin Ruslan Kabalin
            Paul Holden Paul Holden
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 35 minutes
                1d 35m

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