Page MenuHomePhabricator

On New Topic focus is set to content field
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Go to talk page
  • Click button to add new topic

What happens?:
Form focus is moved to textarea

What should have happened instead?:
Form focus should be moved to topic title first

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

I can't reproduce this. The subject field is focused for me.

Now I know this happens when CodeMirror is enabled.

I cannot reproduce this with CodeMirror enabled.

MusikAnimal subscribed.

I am able to repro, and seems to be caused by codemirror.visualEditor.js#162. Note the behaviour only happens on initialization, so if you i.e. use the reply tool then try "Add topic", it works fine as-is.

This behaviour is desirable for normal 2017 editor uses, but not with DiscussionTools "Add topic".

Change #1247666 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CodeMirror@master] CodeMirrorVisualEditor: disable autofocus for DiscussionTools' add topic

https://gerrit.wikimedia.org/r/1247666

MusikAnimal changed the task status from Open to In Progress.Mar 3 2026, 7:32 PM

Related: The auto-focus takes effect in any arbitrary use of VE + CM, such as https://meta.wikimedia.org/wiki/Special:WishlistIntake . The above patch is a quick fix for DT but I'm thinking we need a config option or something to tell CodeMirror that a VE surface should not be auto-focused. I'll look into a follow-up patch for that.

Related: The auto-focus takes effect in any arbitrary use of VE + CM, such as https://meta.wikimedia.org/wiki/Special:WishlistIntake . The above patch is a quick fix for DT but I'm thinking we need a config option or something to tell CodeMirror that a VE surface should not be auto-focused. I'll look into a follow-up patch for that.

This should now be fixed, too, in PS3 of r1247666.

Change #1247666 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirror: restore focus for VE during initialization, as appropriate

https://gerrit.wikimedia.org/r/1247666

Change #1250069 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CodeMirror@master] CodeMirrorVisualEditor: conditionally restore focus during deactivation

https://gerrit.wikimedia.org/r/1250069

Change #1250069 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirrorVisualEditor: conditionally restore focus during deactivation

https://gerrit.wikimedia.org/r/1250069

Bhsd moved this task from Improvement to Done on the MediaWiki-extensions-CodeMirror board.

Change #1251845 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] CodeMirror: restore focus when deactivating

https://gerrit.wikimedia.org/r/1251845

Change #1251845 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirror: restore focus when deactivating

https://gerrit.wikimedia.org/r/1251845