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

'on blur' on the autocomplete element breaks form functionality

XMLWordPrintable

    • MOODLE_36_STABLE
    • MOODLE_35_STABLE, MOODLE_36_STABLE
    • MDL-65102-master
    • Hide

      Test #1

      1. Log in as admin
      2. Go to Site Home
      3. Click on the cog icon and chose "more"
      4. Go to Question bank > questions
      5. Create a new question of any type. For example a True/False question
      6. After you created the question, click on the tag icon next to the question in the question bank
      7. Enter "t1" in the tag element but do not click Enter
      8. Without clicking anywhere else on the page press "Save changes"
      9. Click on the tag icon for the question again and verify that the question is tagged with "t1"
      10. Enter "t2" in the tag element but do not click Enter
      11. Do this step very quick (in less than half a second)
        1. press tab
        2. press enter
      12. Click on the tag icon for the question again and verify that the question is tagged with "t1" and "t2"

      Test #2

      1. Download the test patch: 0001-MDL-65102-calendar-TEST-PATCH.patch to your Moodle instance's root folder.
      2. On your terminal, go to your moodle root folder and apply the test patch: "git am 0001-MDL-65102-calendar-TEST-PATCH.patch"
      3. Purge the caches.
      4. Go to your dashboard and click on month name in the calendar block
      5. Open JS console
      6. Press "New event"
      7. Fill the name of the event
      8. Enter something in the tag element but do not click Enter
      9. Without clicking anywhere else on the page press "Submit"
      10. Verify that you don't see any error in the console coming from createItem
      Show
      Test #1 Log in as admin Go to Site Home Click on the cog icon and chose "more" Go to Question bank > questions Create a new question of any type. For example a True/False question After you created the question, click on the tag icon next to the question in the question bank Enter "t1" in the tag element but do not click Enter Without clicking anywhere else on the page press "Save changes" Click on the tag icon for the question again and verify that the question is tagged with "t1" Enter "t2" in the tag element but do not click Enter Do this step very quick (in less than half a second) press tab press enter Click on the tag icon for the question again and verify that the question is tagged with "t1" and "t2" Test #2 Download the test patch: 0001-MDL-65102-calendar-TEST-PATCH.patch to your Moodle instance's root folder. On your terminal, go to your moodle root folder and apply the test patch: " git am 0001- MDL-65102 -calendar-TEST-PATCH.patch " Purge the caches. Go to your dashboard and click on month name in the calendar block Open JS console Press "New event" Fill the name of the event Enter something in the tag element but do not click Enter Without clicking anywhere else on the page press "Submit" Verify that you don't see any error in the console coming from createItem
    • Workplace for Moodle 3.7

      I am working on a modal form that contains an autocomplete element to add tags and I just found out that if I type a new tag and I press Save on the form (without pressing enter or clicking anywhere else in the form) I get this exception message:

       

       

      jquery-3.2.1.js:3860 jQuery.Deferred exception: Cannot read property 'split' of undefined TypeError: Cannot read property 'split' of undefined at createItem

       

      This happens because on blur tries to work with an element that no longer exists. One proposal to solve this problem that Marina gave me could be adding

      && $('#' + state.inputId).length

      on this if condition:

      --- a/lib/amd/src/form-autocomplete.js
      +++ b/lib/amd/src/form-autocomplete.js
      @@ -709,7 +709,7 @@ function($, log, str, templates, notification, LoadingIcon) {
                       var focusElement = $(document.activeElement);                 // Only close the menu if the input hasn't regained focus.
      -                if (focusElement.attr('id') != inputElement.attr('id')) {
      +                if (focusElement.attr('id') != inputElement.attr('id') && $('#' + state.inputId).length) {
                           if (options.tags) {
                               pendingPromise.then(function() {
                                   return createItem(options, state, originalSelect);

       

            rezaie9 Shamim Rezaie
            davidcarrillo David Carrillo
            Marina Glancy Marina Glancy
            David Monllaó David Monllaó
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 30 minutes
                6h 30m

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