Use lead section when editing page without section marks

The config variable `MFNamespacesWithoutCollapsibleSections` controls
namespaces where section collapsing is disabled. In those namespaces
page is not divided into sections marked with `.mf-section-X` classes.
If that's the case the edit button edits the first section, which is
the whole page.

Bug: T157995
Change-Id: I3ec353575529c1fb11a33fc35c9886cf232e327f
This commit is contained in:
Baha 2017-08-01 18:11:25 -04:00
parent 61f26498a1
commit 975d632d12
1 changed files with 4 additions and 1 deletions

View File

@ -250,8 +250,11 @@
$( '.nojs-edit' ).removeClass( 'nojs-edit' );
$( '#ca-edit a' ).remove();
// FIXME: unfortunately the main page is special cased.
if ( mw.config.get( 'wgIsMainPage' ) || isNewPage || ( leadSection && leadSection.text() ) ) {
if ( mw.config.get( 'wgIsMainPage' ) || isNewPage ||
( leadSection && leadSection.text() ) || page.getSections().length === 0 ) {
// if lead section is not empty, open editor with lead section
// In some namespaces (controlled by MFNamespacesWithoutCollapsibleSections)
// sections are not marked. Use the lead section for such cases.
addEditButton( 0, '#ca-edit' );
} else {
// if lead section is empty or does not exist, open editor with first section