RCFilters: Start the toplinks collapsed/expanded by cookie value
authorMoriel Schottlender <moriel@gmail.com>
Thu, 21 Sep 2017 23:15:47 +0000 (16:15 -0700)
committerMooeypoo <moriel@gmail.com>
Fri, 22 Sep 2017 07:42:17 +0000 (07:42 +0000)
Prevent "jumping" of the content by initializing the top links already
collapsed or expanded depending on the cookie value.

Bug: T176380
Change-Id: I6c494b42ec6f029b60182607faa37feba062b597

includes/specials/SpecialRecentchanges.php
resources/src/mediawiki.rcfilters/styles/mw.rcfilters.less

index 40834cb..34a7714 100644 (file)
@@ -656,12 +656,22 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        $topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
 
                        if ( $this->isStructuredFilterUiEnabled() ) {
+                               // Check whether the widget is already collapsed or expanded
+                               $collapsedState = $this->getRequest()->getCookie( 'rcfilters-toplinks-collapsed-state' );
+                               $collapsedClass = $collapsedState === 'collapsed' ? 'mw-rcfilters-toplinks-collapsed' : '';
+
                                $contentTitle = Html::rawElement( 'div',
-                                       [ 'class' => 'mw-recentchanges-toplinks-title' ],
+                                       [ 'class' => 'mw-recentchanges-toplinks-title ' . $collapsedClass ],
                                        $this->msg( 'rcfilters-other-review-tools' )->parse()
                                );
                                $contentWrapper = Html::rawElement( 'div',
-                                       array_merge( [ 'class' => 'mw-collapsible-content' ], $langAttributes ),
+                                       array_merge(
+                                               [
+                                               'class' => 'mw-recentchanges-toplinks-content mw-collapsible-content ' .
+                                                       $collapsedClass
+                                               ],
+                                               $langAttributes
+                                       ),
                                        $content
                                );
                                $content = $contentTitle . $contentWrapper;
index 80aff74..ba7a70e 100644 (file)
        .rcfilters-head {
                min-height: @rcfilters-head-min-height;
        }
+
        // On the watchlist, reserve a bit more
        .mw-special-Watchlist .rcfilters-head {
                min-height: @rcfilters-wl-head-min-height;
        }
 
-       body:not( .mw-rcfilters-ui-initialized ) .rcfilters-head {
-               opacity: 0.5;
-               pointer-events: none;
-
-               .cloptions {
+       body:not( .mw-rcfilters-ui-initialized ) {
+               .mw-recentchanges-toplinks-content.mw-rcfilters-toplinks-collapsed {
                        display: none;
                }
+
+               .mw-recentchanges-toplinks-title.mw-rcfilters-toplinks-collapsed {
+                       // Hide, but keep the placement so we don't jump
+                       visibility: hidden;
+               }
+
+               .rcfilters-head {
+                       opacity: 0.5;
+                       pointer-events: none;
+
+                       .cloptions {
+                               display: none;
+                       }
+
+               }
        }
 
        .rcfilters-container {