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

Rangy steals focus on load

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 2.9.5, 3.0.3, 3.7.3, 3.8.1, 3.9
    • Text editor Atto
    • MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
      1. Open the calendar
      2. Click on the "New event" button
        1. Confirm that the modal is the currently focused item

      I've been getting frustrated with something causing focus to change during page load and have tracked it down to Rangy.

      When you refresh a page with an mform, if you select a basic text element and start typing into it, the focus is lost when Atto loads.

      Looking into it further I've tracked this down to rangy.

      To track this down, add the following code just inside the closure for lib/amd/src/first.js:

      $('*').on('focus blur', function(event) {debugger;});
      

      Open a form page (I used add new forum) and click in the first text box as soon as the page loads as early as possible

      I can be typing something and suddenly the focus jumps.

      This seems to be coming from Rangy's feature detection and specifically from this line: https://github.com/moodle/moodle/blob/master/lib/editor/atto/yui/src/rangy/js/rangy-textrange.js#L100

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Tim Hunt Tim Hunt
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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