Page MenuHomePhabricator

Mobile edit icon does not always point to correct section id
Closed, ResolvedPublic


Clicking edit on points to #/editor/1
Expected: Should point to #/editor/0

Editing in mobile (both beta and not), when I click the pencil icon to edit section "n" I get taken to section "n-1". Impossible to edit final section (and as I do a lot of stubsorting this is a huge problem). The pencil icon is not shown beside first section. It has happened before and then been ok until today.

I will be mobile-only for next few days with no email access, so if there is a substantial comment or progress please drop a note on my en. wiki talk page. Thanks.

Event Timeline

PamD raised the priority of this task from to Needs Triage.
PamD updated the task description. (Show Details)
PamD added a subscriber: PamD.
TTO set Security to None.
TTO added subscribers: TTO, Jdlrobson.

Does this relate to the mobile app (e.g. Wikipedia iOS app), or to the mobile website (e.g.

Sorry, I think it's website not app. In Android on Galaxy Ace 4.

Please can you clarify on what pages you see this. Is this every page or only certain pages?

You say you get taken to edit n-1 so what happens when you click edit on the first button does the editor even load?

Deskana renamed this task from Mobile app edit icon giving wrong section to Mobile edit icon giving wrong section.Dec 28 2015, 11:05 PM

Sorry not to reply sooner - I've been away from email, and hence Phabricator notifications, for a few days.

It's an intermittent problem.

Currently,looking at some of "Category:Stubs":

"FileCloud" Pencil icon appears beside lead sentence; clicking it lets me edit lead section.

No pencil icon appears beside "Client"

Pencil icon appears beside "Storage Types": clicking it lets met edit "Client" section

Pencil icon appears beside "See also": leads to "Storage Types"

Pencil icon appears beside "References": leads to "See also"

I can't edit the "References" section on mobile, where (as I see on laptop) the "Stub" tag and categories are found. Perhaps it's significant that there is no text here which shows on screen - there is not even a "Reflist" template, the refs are listed at the end of the article as happens by default.

Other current stubs:

"Law of Sweden": similar problems: pencil icon at lead section, and at sections "Statutes" onward, but not at "Constitution". Each leads to previous section, so the last icon, at "External links", lets me edit the "References" section but not the "External links" section, ... though this contains a real visible External link, so my vague hypothesis above seems wrong.

But "Bright Star (musical)" has icons for lead and "References", its only section, so no problem.

"Boy 7" has 3 icons - lead and 2 sections - and no problem

"Evangelical Lutheran Church - Peru" is OK

"Gloucestershire Archives" OK

"Júlio Gonçalves" OK

"Jordan Air Ambulance Center" is a problem - no icon for "See also", so icon at "External links" leads to "References" (and icon at "References leads to "See also")

"Keith Lewis (cornerback)" OK (only lead plus "References")

"Lurë Lakes" just like the above only has a lead plus a "References" section, but this time there is no icon for the "References". The pencil icon at the lead only shows me the lead section, so I cannot edit the category or the stub tag which, as I see on laptop, are present under "References".

I hope this sample is enough to help! Good luck in trying to find some pattern of what is going on.

I have now found a first example where two sections, not just one, have no edit icon: "Vijayadasami (film)" Current version is at I found the problem both last night (about 8 hours ago) and right now. There are no edit icons on mobile for the sections "Cast" and "Release", and the edit icons for "References" and "External links" each lead back two sections (ie from EL to "Release").

Jdlrobson renamed this task from Mobile edit icon giving wrong section to Mobile edit icon at top of page points to 2nd section.Jan 5 2016, 6:59 PM
Jdlrobson triaged this task as High priority.
Jdlrobson updated the task description. (Show Details)

The new title of this bug seems confusing: the problem is that the first (non-top) section has no edit icon, and the edit icons for later sections each point to the immediately previous section. In one example the first and second sections had no icons, and the remaining icons pointed to the last-but-one section.

TTO renamed this task from Mobile edit icon at top of page points to 2nd section to Mobile edit icon sometimes points to the previous section of the page.Jan 6 2016, 1:46 AM

I think Jon had it the wrong way around.

Jdlrobson renamed this task from Mobile edit icon sometimes points to the previous section of the page to Mobile edit icon does not always point to correct section id.Jan 6 2016, 5:05 PM
Jdlrobson added a project: Contributors-Team.

Example I saw was edit link points to section 1 rather than 0 which is next section.

There may be similar symptoms here but I suspect they are all linked to same problem.

Florian added a subscriber: Florian.

That's partly a content problem and partly how MobileFrontend handles the editor. A little bit of background:

The idea is, that the editor (on an existing page) never starts with empty content. That means, if you open a page, where the first (called lead) section doesn't has any content, and click the edit button near the title, you shouldn't see the empty (very limited) mobile editor (where normally the text appears). That would be confusing, because the user thought, that he edits the page he sees, which probably has content, but it starts in the first section. So, MobileFrontend will start the editor with the section count 1, which normally should have content and where the user can edit. Here is a little test page: If you click on the edit button near the title, you'll get the first section, instead of the lead section (which is empty, see the wikisource). That, as it is, is useful I think, especially for "new" (mobile) editors.

So far, so good. Now a little bit implementation theory. The code, which handles this (in a nutshell) is:

// Make sure we never create two edit links by accident
// FIXME: split the selector and cache it
if ( $caEdit.find( '.edit-page' ).length === 0 ) {
	// FIXME: unfortunately the main page is special cased.
	if ( mw.config.get( 'wgIsMainPage' ) || isNewPage || page.getLeadSectionElement().text() ) {
		// if lead section is not empty, open editor with lead section
		addEditButton( 0, '#ca-edit' );
	} else {
		// if lead section is empty, open editor with first section
		addEditButton( 1, '#ca-edit' );

The decision matrix is really simple and understandable: If the page is the main page, or a new page (not created yet), or the first (lead) section has some (visible) text, the editor button at the top right gets a "0" as a target section (the lead section), otherwise it get's the "1", which is the first section with text (hopefully). The problem here is the "getLeadSection().text()" method. The lead section is indetified by the first nested div inside the .content css class (ref). This first div should be created by our MobileFormatter, which creates/wraps the lead section inside this new div container (which allows us to identify it as the lead section) in a super magic way (I currently doesn't really remember how we did it, I assume somewhere in the collapsible section php code). Now, the problem is, that we don't do that for special pages or category pages (ref).

What the code now does is, that it takes the first div element inside the page html, which is unfortunately the "shortcuts" template:

<div style="position:relative;top:-3em"><span id="CAT:STUB"></span><span id="CAT:STUBS"></span></div>

Calling .text() on this element will return an empty string, which casts to boolean false, which is why the mobile editor thinks, that there's no content in the first section and it starts the editor with the last/second section (see also).

Ok, but how to fix this? The easiest and the quick fix would be to reorganise the wikitext of the page to workaround this problem. For the given category page, I did this (diff), I think it's not a big deal, that the "random page in..." link is now _before_ the shortcut box (however, you could change this easily, too). However, this isn't a solution, which is very suitable for our users, so I'll invest some more work to find out how we can solve this bug with a better infrastructure, e.g. how we can get the lead section easier :)

Thanks for your patience!

Btw.: I'll remove the Contributors-Team, as this is definitely a bug in MobileFrontend (and therfore a Readers-Web-Backlog Department problem :P).

Change 263081 had a related patch set uploaded (by Florianschmidtwelzow):
Fix lead section handling in MobileFrontend

Does the explanation for the problem account for the page where two sections had no edit icons and later icons referred to last-but-one section? See my post of 1 Jan 09:14.

Does the explanation for the problem account for the page where two sections had no edit icons and later icons referred to last-but-one section? See my post of 1 Jan 09:14.

I can't reproduce this problem, sorrry. In diff view, you normaly don't get section edit icons in MobileFrontend iirc. But, if I see it correctly: no, this could not be the problem, the lead section is identified correctly there (in fact, pages in the article namespace shouldn't be affected at all).

Do you have an actual page, where I can see the problem you describe?

All the problems I have encountered and reported have been in article namespace - please read my earlier detailed posts. It was someone else who found a problem with Category:Stubs.

The article "Vijayadasami (film)" still has not just one but two missing edit icons. There is an edit icon for the lead, no problem. There is no edit icon for either "Cast" or "Release". The edit icon at "References" leads me to the "Cast" section; the icon for "External links" leads me to "Release". It is impossible to access those last two sections to edit them. (And as I spend a lot of time stub-sorting, inaccessibility of the final section of an article is a serious obstacle to my constructive editing). This article has been edited (stub-sorted by me, on my laptop) since I reported the problem, but it still has the problem - my mobile is beside me as I type. The current version of the article is at

Looking back at my detailed post of 31 Dec 7:28pm, and picking another example of a file which was then problematic... "Jordan Air Ambulance Center" still has no edit icon for the section after the lead, "History", and the final icon, for "External link", still leads me to the previous section, "References", making it impossible to edit the end of the article.

Is that enough?

Sorry, I can't reproduce the problems you described at any page, nor on neither on, nor on I've edit icons at each section. Which browser do you use? Can you take a screenshot and upload it here?

No, I do not know how to get a screen shot off my mobile phone. It's a Samsung Galaxy Ace 4, using Android 4.4.4 I believe I'm using a Beta version of the mobile access. The URLs start

I've just experimented with my mobile and am constantly confused about various different interfaces. In one dreadful version, the "Category:Stubs" page is useless as it displays a set of 26 links to the A-Z sections, while I prefer to cast an eye over the whole category to decide which stubs to work on.

If, in "Settings", I unclick "Beta" and hit Save, I seem to get a version which doesn't offer me the option to go back to Beta. But somehow I seem to stumble around and get back to it.

It should be possible to use the "Volume Down" + "Power" key (press at the same time) to get a screenshot.

It should be always possible to get back to the beta mode in the settings :)

Sorry, screenshot instructions didn't work on my phone.

I now find that if I click on "View in Browser" I can edit the otherwise inaccessible sections.

Looking at "Qilin, Anhui" just now:

  • In my normal mobile view, no edit icon (pencil) beside "References"; only an edit icon beside lead section, clicking which allows me to edit lead section only.
  • Clicking on "View page in browser" leads to a view with no visible edit icons ... but clicking in the place where they would be allows me to edit either lead section or "References" section.
  • Edited the "References" section successfully: it returns me to the original view, where "View page in browser" is an option.

To be honest I'm never sure whether I'm using an app or not: looking at the "history" list in "Window manager", I see the Qilin, Anhui page shown both with the "W" logo and with the Globe logo.

So it seems that even in articles where there is a missing edit icon, which usually makes the last section inaccessible for editing, it is sometimes (always?) possible to do that editing by going to "View page in browser". This all seems very confusing, but I'm glad to have found a work round which will enable me to continue to stub-sort in mobile view, albeit with an extra step each time.

Does this relate to the mobile app (e.g. Wikipedia iOS app), or to the mobile website (e.g.

Sorry, I think it's website not app. In Android on Galaxy Ace 4.

I now find that if I click on "View in Browser" I can edit the otherwise inaccessible sections.

-> View in Browser ??? *confused*

Do we really discuss about the website (which you can access with your web browser) or about the Wikipedia app? What do you see, if you open the left navigation bar? If it's the app, we possibly could reopen T65874: Edit link loads the wrong section in some cases (for Mobileview API).

Btw.: I'm pretty sure you use the app. The article "Qilin, Anhui" in mobile web:

Unbenannt.PNG (777×949 px, 42 KB)

and in the app:

Screenshot_20160113-000237.png (1×1 px, 154 KB)

I seem to use both, but yes, it's the app view which I recognise.

My procedure is:

  • Click on "Internet" icon on phone
  • Click on "Bookmarks" icon
  • See a Bookmarks list which includes "Stubs" with a "W" icon and also "Watchlist" with a globe icon.

-If I choose Watchlist, then I get a watchlist divided into "All", "Pages", "Talk" and "Other". If I click on an item on it I get a display of the diff; clicking on the article title goes through a grey screen with a large central "W" to (Usually) a "Choose an action" panel offering Chrome or Internet. I choose "Internet" and it leads me to a display looking like your app display (more or less). (That Chrome/Internet option doesn't always happen).

  • If I choose Stubs, I get a listing (currently displaying the blue "Wikipedia turns 15" banner) from which I can select items (and it lists a page of up to 200 stubs, showing them all, while another format I've sometimes fallen into only offers 26 A-Z section headings to click on, which is unhelpful). If I select an item it goes through that grey "W" screen, briefly shows a list of recent pages each with an icon which is perhaps a page stereotype (grey oblong, some lines to imitate text, white square top right), and ends up with an article like your app illustration.

I've bookmarked those two listings, at some point in the past, having found them as my useful access point to Wikipedia. I remain confused!

Behaviour seems to have changed - edit icon now points to lead but subsequent sections are not editable.
It seems that the section wrapping code is not running on this page.
Edit icons however are not showing.

This is because of the line $ 'div' ) not true and thus the open-block class doesn't get added to the heading and thus .open-block .edit-page never changes the edit icon to display inline-block (in that case it should just be shown)

@Florian I think we can fix this with some minor JS/CSS changes. I would much rather we don't touch the MobileFormatter code.

@Jdlrobson: the problem was (generally) solved after I edited the page: so, I'm pretty sure, that the underlying problem itself isn't fixed (but haven't tested). I'm not sure, if some JS/CSS is enough, the problem is definitely the MobileFormatter (I don't like this, too, but... :P). Btw. MobileFormatter currently doesn't run on Category pages, IIRC.

I'm still having the problem of inability to edit final section of many articles because the edit icons are loading the wrong sections, but have today found a new problem which is probably related.

When I look at Wikipedia talk:Disambiguation, in the app, I'm seeing sections under the wrong section headings. eg section heading "Freedom of Information ...", text below it starts "I was workindg on disambiguation of Posthumous...". It's reproducible on that talk page and also Wikipedia talk:Wikiproject Disambiguation. (Both last edited at 02:00 today)

I've cracked the question of how to do a screenshot (Home + Power) by looking in the online user manual for my phone:"If all else fails read the instructions". But can't right now get phone to communicate with laptop to upload. Will try again later.

It would be great, if you could open a new task regarding the app :/ Btw.: As far as I know, talk pages aren't supported by the app :]

Jdlrobson lowered the priority of this task from High to Medium.Jan 27 2016, 7:07 PM
Jdlrobson lowered the priority of this task from Medium to Lowest.Feb 9 2016, 1:13 AM

@Florian I ran into this over the weekend and it was due to a References heading like this:


If this is the case I think rather than working around this problem in the MobileFormatter we should help detect this in the editor.

If there are other examples where this is not the case please share them (with revision id). Right now though this seems like a minority of articles and I really don't think we should work around every edge case. Any changes here could very badly backfire on us and having even greater consequences.

@Jdlrobson: Isn't your problem slightly different from the one described here? If I reproduce the wikitext from the version with ==References= locally, I can still edit all sections (and any section edit link opens the desired section). This task is about the problem, that I can't edit the lead section on pages, where the first part of the content is a div element (and the lead edit icon opens the first section, instead of section 0). To fix this problem, we would need to change the MobileFormatter (as it currently doesn't handle to wrap the lead section on other pages as the ones of the main namespace, but the editor code expects to have such a wrapped lead section).

@Florian in that example I was unable to edit the lead section too. The formatter gets confused if higher headings appear below lower one (e.g. h1s that are below h2s)

Can you give me several test cases (in raw wikitext) where the formatter breaks that your formatter changes fix.

The simplest case would be something like:

<div class="just an empty div"></div>
The other page text goes here.

== testsection 1 ==

The long(er) version:

{{hidden category}}
{{empty category}}
<center>{{Random page in category}}</center>

This is a [[Wikipedia:Category|category]] of '''[[Wikipedia:Stub|stub articles]]'''. Please check the articles listed here and remove the {{tlp|stub}} tag from them if they have been expanded since the tag was originally added.

Please put any stub-sized articles into an appropriate '''[[Wikipedia:Stub categories|stub category]]''', by using a [[Wikipedia:WikiProject Stub sorting/Stub types|stub tag for a specific topic]] instead of a generic stub tag, where possible; for example, by using the {{tl|art-stub}} tag or one of its subtypes for art-related stubs. Ideally, this category should be empty or close to empty.

{{purge button|right}}
See [[Wikipedia:WikiProject Stub sorting/Stub types]] for a complete listing in an organized catalogue of topics. Several tools are available which are helpful in finding stubs related to a given category. These - and other information about stubs - can be found listed at [[Wikipedia:Stub]].

Since this particular category is added to very regularly when people use the [[:Template:Stub|stub template]], active efforts to move stubs into topic stubs, or convert stubs into larger articles, are greatly appreciated. If you would like to help, please visit the [[Wikipedia:WikiProject Stub sorting|Stub-sorting WikiProject]] for more information.

== See also ==
{{Commons category|Stub icons}}
* [[:Category:All stub articles]]
* [[:Category:Articles to be expanded]]
* [[:Category:Stub categories]]

{{Category TOC}}

[[Category:WikiProject Stub sorting]]
[[Category:Top-level stub categories|*]]


<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->


1-- This module implements {{shortcut}}.
3-- Set constants
4local CONFIG_MODULE = 'Module:Shortcut/config'
6-- Load required modules
7local checkType = require('libraryUtil').checkType
8local yesno = require('Module:Yesno')
10local p = {}
12local function message(msg, ...)
13 return mw.message.newRawMessage(msg, ...):plain()
16local function makeCategoryLink(cat)
17 return string.format('[[%s:%s]]',[14].name, cat)
20function p._main(shortcuts, options, frame, cfg)
21 checkType('_main', 1, shortcuts, 'table')
22 checkType('_main', 2, options, 'table', true)
23 options = options or {}
24 frame = frame or mw.getCurrentFrame()
25 cfg = cfg or mw.loadData(CONFIG_MODULE)
26 local isCategorized = yesno(options.category) ~= false
28 -- Validate shortcuts
29 for i, shortcut in ipairs(shortcuts) do
30 if type(shortcut) ~= 'string' or #shortcut < 1 then
31 error(message(cfg['invalid-shortcut-error'], i), 2)
32 end
33 end
35 -- Make the list items. These are the shortcuts plus any extra lines such
36 -- as options.msg.
37 local listItems = {}
38 for i, shortcut in ipairs(shortcuts) do
39 listItems[i] = string.format('[[%s]]', shortcut)
40 end
41 table.insert(listItems, options.msg)
43 -- Return an error if we have nothing to display
44 if #listItems < 1 then
45 local msg = cfg['no-content-error']
46 msg = string.format('<strong class="error">%s</strong>', msg)
47 if isCategorized and cfg['no-content-error-category'] then
48 msg = msg .. makeCategoryLink(cfg['no-content-error-category'])
49 end
50 return msg
51 end
53 local root = mw.html.create()
55 -- Anchors
56 local anchorDiv = root
57 :tag('div')
58 :css('position', 'relative')
59 :css('top', '-3em')
60 for i, shortcut in ipairs(shortcuts) do
61 local anchor = mw.uri.anchorEncode(shortcut)
62 anchorDiv:tag('span'):attr('id', anchor)
63 end
65 root:newline() -- To match the old [[Template:Shortcut]]
67 -- Shortcut heading
68 local shortcutHeading
69 do
70 local nShortcuts = #shortcuts
71 if nShortcuts > 0 then
72 shortcutHeading = message(cfg['shortcut-heading'], nShortcuts)
73 shortcutHeading = frame:preprocess(shortcutHeading)
74 shortcutHeading = shortcutHeading .. '\n'
75 end
76 end
78 -- Shortcut box
79 local shortcutList = root
80 :tag('table')
81 :addClass('shortcutbox noprint')
82 :css('float', 'right')
83 :css('border', '1px solid #aaa')
84 :css('background', '#fff')
85 :css('margin', '.3em .3em .3em 1em')
86 :css('padding', '3px')
87 :css('text-align', 'center')
88 :tag('tr')
89 :tag('th')
90 :addClass('plainlist')
91 :css('border', 'none')
92 :css('background', 'transparent')
93 :tag('small')
94 :wikitext(shortcutHeading)
95 :tag('ul')
96 for i, item in ipairs(listItems) do
97 shortcutList:tag('li'):wikitext(item)
98 end
100 -- Output an error category if the first shortcut doesn't exist
101 if isCategorized
102 and shortcuts[1]
103 and cfg['first-parameter-error-category']
104 then
105 local title =[1])
106 if not title or not title.exists then
107 root:wikitext(makeCategoryLink(cfg['first-parameter-error-category']))
108 end
109 end
111 return tostring(root)
114function p.main(frame)
115 local args = require('Module:Arguments').getArgs(frame, {
116 wrappers = 'Template:Shortcut'
117 })
119 -- Separate shortcuts from options
120 local shortcuts, options = {}, {}
121 for k, v in pairs(args) do
122 if type(k) == 'number' then
123 shortcuts[k] = v
124 else
125 options[k] = v
126 end
127 end
129 -- Compress the shortcut array, which may contain nils.
130 local function compressArray(t)
131 local nums, ret = {}, {}
132 for k in pairs(t) do
133 nums[#nums + 1] = k
134 end
135 table.sort(nums)
136 for i, num in ipairs(nums) do
137 ret[i] = t[num]
138 end
139 return ret
140 end
141 shortcuts = compressArray(shortcuts)
143 return p._main(shortcuts, options, frame)
146return p

In fact, it doesn't matter, what you use, the importnat part is the empty first div, and that you open a page, which currently isn't processed by MobileFormatter (e.g. catgeory pages, talk pages (iirc) or file pages).

Is there any way we can clean up those empty divs outside the MobileFormatter (why are they empty...)?

They're used to allow linking to the element:

In fact: They aren't really "empty", they just don't have a visible text content (there are some span elements to allow linking with a hash fragment).

I don't see an easy way to clean this up entirely :/

Change 263081 merged by jenkins-bot:
Fix lead section handling in MobileFrontend

Well fingers crossed the fix worked. I was brave and merged. Let's hope this doesn't escalate into more bugs. @PamD this should roll out next Thursday (10th) so please do let us know if you see this issue after that or anything similar.

Thanks. I look forward to not seeing the problem again, and will let you know if I see it after next Thursday.

Unfortunately the problem has not been solved. I have observed the problem several times since 10th Sept, but am now sitting with phone and laptop together so can report on it.

I cannot edit the final section of on my mobile because the edit icon for "External links" leads to "References", etc. There is an edit icon for the lead section, but no icon for the first headed section, "Public Statements", and its first subheading "On Barack Obama". There are icons for the next subheading, "On the assassination of John F. Kennedy", and all other headings, but each one leads me to the previous section instead of where I am aiming.

Looking at other entries in Category:Stubs:-

Aam Aadmi Party Youth Wing - ok
Abraham de Villiers - ok
Adung Long - ok
Angkatan Amanah Merdeka - ok
Bansaha - ok
Brussels Gallery Weekend - ok
Cascade impactor - no sections, ok
Monita Chatterjee - no icon for either "References" or "External links" sections
Jamie Clay - ok
Club Dancer 2016 - no sections, ok
Coolfont Resort - no sections, ok
Copper tape - ok
Gil Cuadros - ok
Delegation - ok
Digital billboard - no icon for first heading "Safety concerns", so icon at "References" leads to "Safety concerns" instead

I could continue, but that's a random selection of articles - stubs starting at initial "A". I see no obvious pattern as to why some show this problem and others not, but there must be some subtle thread there.

Mary Lou Bruner was only created on 19th March (I wondered whether articles created before the change might be the problem ... but not so.) Digital billboard has been around since 2010, though only recently labelled as a stub.

I look forward to hearing more about this still-unresolved problem.

I was previously asked to provide a screen shot: If I succeed in getting one on my phone, where should I upload it to, or email it to, if it would still be useful?

To clarify: the problem described above is when using the app.

And my app settings tells me I'm in Beta-2016-02-10.

@PamD since this issue relates to the app not the web I've created a new task for you - T130698

Just to report I'm encountering the following error on

Uncaught TypeError: Cannot read property 'text' of null

page.getLeadSectionElement() returns null here:

// FIXME: unfortunately the main page is special cased.
if ( mw.config.get( 'wgIsMainPage' ) || isNewPage || page.getLeadSectionElement().text() ) {
	// if lead section is not empty, open editor with lead section
	addEditButton( 0, '#ca-edit' );
} else {
	// if lead section is empty, open editor with first section
	addEditButton( 1, '#ca-edit' );