Page MenuHomePhabricator

CodeMirror doesn't support focus/blur events for the editing area
Open, NormalPublic

Description

Despite supporting .val() and .textSelection (added by jquery.textSelection module) methods for $( '#wpTextbox1' ), CodeMirror has no support for .focus() & .blur() methods and corresponding events.

In Chrome, listening to these events for the .CodeMirror-code element saves the day, but for some reason the DOM for Chrome and Firefox (at least these two) differs, and in Firefox, I have found no reliable way to attach the said event listeners to the editing area. You can listen to .CodeMirror textarea which is present only in Firefox, but it isn't present in the DOM from the start, and—what makes the things even worse—there is no mw.hook events created for CodeMirror (see T174811: Support JavaScript hook events for CodeMirror), so you can't catch the moment when CodeMirror is initialized to attach a listener. mw.hook( 'wikipage.editform' ) is useless.

Because of this issue an important ruwiki script has broken in Firefox for many users after CodeMirror came out of beta last week.

Event Timeline

Restricted Application added a project: Community-Tech. · View Herald TranscriptJun 18 2018, 8:56 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Unrelated to the issue at hand:

... after making CodeMirror opt-out last week.

It's not supposed to be opt-out :( We've had a few ambiguous reports of this but with all of my test accounts (that had never used CodeMirror), and new test accounts that I created, CodeMirror is off by default as it should be. @MaxSem Any idea what could have caused this?

@Jack_who_built_the_house Did you ever try out CodeMirror on beta labs or test wiki? If you ever turned it on, it will show up as on by default.

Niharika triaged this task as Normal priority.

Okay I assume I'm wrong about opt-out (just too many fellow users reported that). The issue still stands though.

Vvjjkkii renamed this task from CodeMirror doesn't support focus/blur events for the editing area to jpaaaaaaaa.Jul 1 2018, 1:02 AM
Vvjjkkii raised the priority of this task from Normal to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot lowered the priority of this task from High to Normal.
CommunityTechBot renamed this task from jpaaaaaaaa to CodeMirror doesn't support focus/blur events for the editing area.
CommunityTechBot added a subscriber: Aklapper.