If there are less than 3 entries, the browser still tries to render as it would
appear as if there are 3 columns, so the final rendering is broken. So don't apply
CSS columns and just show a normal list if there are less than 3 results. This also
matches the behavior of CategoryViewer.
Bug: T117887
Change-Id: Ie6ac0e1174ff8cc14008f39a91c95bcd6f616353
);
if ( $res->numRows() > 0 ) {
);
if ( $res->numRows() > 0 ) {
- $out = Html::openElement( 'div', array( 'class' => 'mw-allpages-body' ) );
- $out .= Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) );
+ $out = Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) );
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::newFromRow( $s );
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::newFromRow( $s );
$n++;
}
$out .= Html::closeElement( 'ul' );
$n++;
}
$out .= Html::closeElement( 'ul' );
- $out .= Html::closeElement( 'div' );
+
+ if ( $res->numRows() > 2 ) {
+ // Only apply CSS column styles if there's more than 2 entries.
+ // Otherwise, rendering is broken as "mw-allpages-body"'s CSS column count is 3.
+ $out = Html::rawElement( 'div', array( 'class' => 'mw-allpages-body' ), $out );
+ }
$n = 0;
if ( $res->numRows() > 0 ) {
$n = 0;
if ( $res->numRows() > 0 ) {
- $out = Html::openElement( 'div', array( 'class' => 'mw-prefixindex-body' ) );
- $out .= Html::openElement( 'ul', array( 'class' => 'mw-prefixindex-list' ) );
+ $out = Html::openElement( 'ul', array( 'class' => 'mw-prefixindex-list' ) );
$prefixLength = strlen( $prefix );
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$prefixLength = strlen( $prefix );
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
- $out .= "<li> $link </li>\n";
+ $out .= "<li>$link</li>\n";
$n++;
}
$out .= Html::closeElement( 'ul' );
$n++;
}
$out .= Html::closeElement( 'ul' );
- $out .= Html::closeElement( 'div' );
+
+ if ( $res->numRows() > 2 ) {
+ // Only apply CSS column styles if there's more than 2 entries.
+ // Otherwise rendering is broken as "mw-prefixindex-body"'s CSS column count is 3.
+ $out = Html::rawElement( 'div', array( 'class' => 'mw-prefixindex-body' ), $out );
+ }
!! wikitext
{{Special:Prefixindex/Xyzzyx}}
!! html
!! wikitext
{{Special:Prefixindex/Xyzzyx}}
!! html
-<div class="mw-prefixindex-body"><ul class="mw-prefixindex-list"><li> <a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a> </li>
-</ul></div>
+<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
+</ul>
{{Special:Prefixindex/Xyzzyx}}
{{Special:Prefixindex/Xyzzyx}}
!! html
{{Special:Prefixindex/Xyzzyx}}
{{Special:Prefixindex/Xyzzyx}}
!! html
-<div class="mw-prefixindex-body"><ul class="mw-prefixindex-list"><li> <a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a> </li>
-</ul></div>
-<div class="mw-prefixindex-body"><ul class="mw-prefixindex-list"><li> <a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a> </li>
-</ul></div>
+<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
+</ul>
+<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
+</ul>