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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 3.9.3, 3.10, 3.11, 4.0
    • Fix Version/s: None
    • Component/s: JavaScript, Privacy
    • Labels:
      None
    • Testing Instructions:
      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)
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • Pull 3.9 Branch:
      MDL-70395-MOODLE_39_STABLE
    • Pull 3.10 Branch:
      MDL-70395-MOODLE_310_STABLE
    • Pull 3.11 Branch:
      MDL-70395-MOODLE_311_STABLE
    • Pull Master Branch:
      MDL-70395-master

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kabalin Ruslan Kabalin
              Reporter:
              kabalin Ruslan Kabalin
              Peer reviewer:
              Paul Holden Paul Holden
              Integrator:
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Participants:
              Component watchers:
              Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

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