<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[41903] trunk/src: Customize: Unstick filter pane in Theme selector</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/41903">41903</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/41903","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>obenland</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-10-18 15:10:19 +0000 (Wed, 18 Oct 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Customize: Unstick filter pane in Theme selector

Prevents the filter pane from blocking the view of theme search results when it's open.
Users are now able to just scroll to view results.

Props rclations.
Fixes <a href="https://core.trac.wordpress.org/ticket/42212">#42212</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsscustomizecontrolscss">trunk/src/wp-admin/css/customize-controls.css</a></li>
<li><a href="#trunksrcwpadminjscustomizecontrolsjs">trunk/src/wp-admin/js/customize-controls.js</a></li>
<li><a href="#trunksrcwpincludescustomizeclasswpcustomizethemessectionphp">trunk/src/wp-includes/customize/class-wp-customize-themes-section.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsscustomizecontrolscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/customize-controls.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/customize-controls.css     2017-10-18 15:08:58 UTC (rev 41902)
+++ trunk/src/wp-admin/css/customize-controls.css       2017-10-18 15:10:19 UTC (rev 41903)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1761,6 +1761,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">        z-index: 20;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+@media screen and (min-width: 1670px) {
+       .control-panel-themes .customize-themes-full-container {
+               width: 82%;
+               right: 0;
+               left: initial;
+       }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .modal-open .control-panel-themes .customize-themes-full-container {
</span><span class="cx" style="display: block; padding: 0 10px">        overflow-y: visible;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1835,7 +1843,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        display: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.themes-filter-bar .filter-drawer {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.filter-drawer {
</ins><span class="cx" style="display: block; padding: 0 10px">         box-sizing: border-box;
</span><span class="cx" style="display: block; padding: 0 10px">        width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px">        position: absolute;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1848,7 +1856,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        border-bottom: 1px solid #ddd;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.themes-filter-bar .filter-group {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.filter-drawer .filter-group {
</ins><span class="cx" style="display: block; padding: 0 10px">         margin: 0 25px 0 0;
</span><span class="cx" style="display: block; padding: 0 10px">        width: calc( (100% - 75px) / 3);
</span><span class="cx" style="display: block; padding: 0 10px">        min-width: 200px;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2122,6 +2130,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">        border-bottom: 1px solid #ddd;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+@media screen and (min-width: 1670px) {
+       .customize-preview-header.themes-filter-bar {
+               width: 82%;
+               right: 0;
+               left: initial;
+       }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .themes-filter-bar .themes-filter-container {
</span><span class="cx" style="display: block; padding: 0 10px">        margin: 0;
</span><span class="cx" style="display: block; padding: 0 10px">        padding: 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2149,6 +2165,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px">                margin: 0 0 25px 0;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        .filter-drawer {
+               top: 46px;
+       }
</ins><span class="cx" style="display: block; padding: 0 10px">         .wp-customizer .theme-browser .themes {
</span><span class="cx" style="display: block; padding: 0 10px">                padding: 0 0 25px 25px;
</span><span class="cx" style="display: block; padding: 0 10px">                overflow: hidden;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2163,7 +2182,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> @media screen and (max-width:1018px) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        .themes-filter-bar .filter-group {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .filter-drawer .filter-group {
</ins><span class="cx" style="display: block; padding: 0 10px">                 width: calc( (100% - 50px) / 2);
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2180,7 +2199,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                min-width: 200px;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        .themes-filter-bar .filter-drawer {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .filter-drawer {
</ins><span class="cx" style="display: block; padding: 0 10px">                 top: 86px;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2190,7 +2209,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> @media screen and (max-width:792px) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        .themes-filter-bar .filter-group {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .filter-drawer .filter-group {
</ins><span class="cx" style="display: block; padding: 0 10px">                 width: calc( 100% - 25px);
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2202,6 +2221,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* Mobile - toggle between themes and filters */
</span><span class="cx" style="display: block; padding: 0 10px"> @media screen and (max-width:600px) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        .filter-drawer {
+               top: 132px;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         .wp-full-overlay.showing-themes .control-panel-themes .filter-themes-count .filter-themes {
</span><span class="cx" style="display: block; padding: 0 10px">                display: block;
</span><span class="cx" style="display: block; padding: 0 10px">                float: right;
</span></span></pre></div>
<a id="trunksrcwpadminjscustomizecontrolsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/customize-controls.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/customize-controls.js       2017-10-18 15:08:58 UTC (rev 41902)
+++ trunk/src/wp-admin/js/customize-controls.js 2017-10-18 15:10:19 UTC (rev 41903)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1799,21 +1799,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // Toggle feature filters.
</span><span class="cx" style="display: block; padding: 0 10px">                        section.contentContainer.on( 'click', '.feature-filter-toggle', function( e ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $( e.currentTarget )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         var $themeContainer = $( '.customize-themes-full-container' ),
+                                       $filterToggle = $( e.currentTarget );
+                               section.filtersHeight = $filterToggle.parent().next( '.filter-drawer' ).height();
+
+                               if ( 0 < $themeContainer.scrollTop() ) {
+                                       $themeContainer.animate( { scrollTop: 0 }, 400 );
+
+                                       if ( $filterToggle.hasClass( 'open' ) ) {
+                                               return;
+                                       }
+                               }
+
+                               $filterToggle
</ins><span class="cx" style="display: block; padding: 0 10px">                                         .toggleClass( 'open' )
</span><span class="cx" style="display: block; padding: 0 10px">                                        .attr( 'aria-expanded', function( i, attr ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                                return 'true' === attr ? 'false' : 'true';
</span><span class="cx" style="display: block; padding: 0 10px">                                        })
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        .next( '.filter-drawer' ).slideToggle( 180, 'linear', function() {
-                                               if ( 0 === section.filtersHeight ) {
-                                                       section.filtersHeight = $( this ).height();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 .parent().next( '.filter-drawer' ).slideToggle( 180, 'linear' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                        // First time, so it's opened.
-                                                       section.contentContainer.find( '.themes' ).css( 'margin-top', section.filtersHeight + 76 );
-                                               }
-                                       });
-                               if ( $( e.currentTarget ).hasClass( 'open' ) ) {
-                                       section.contentContainer.find( '.themes' ).css( 'margin-top', section.filtersHeight + 76 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( $filterToggle.hasClass( 'open' ) ) {
+                                       var marginOffset = 1018 < window.innerWidth ? 50 : 76;
+
+                                       section.contentContainer.find( '.themes' ).css( 'margin-top', section.filtersHeight + marginOffset );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 } else {
</span><span class="cx" style="display: block; padding: 0 10px">                                        section.contentContainer.find( '.themes' ).css( 'margin-top', 0 );
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span></span></pre></div>
<a id="trunksrcwpincludescustomizeclasswpcustomizethemessectionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/customize/class-wp-customize-themes-section.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/customize/class-wp-customize-themes-section.php     2017-10-18 15:08:58 UTC (rev 41902)
+++ trunk/src/wp-includes/customize/class-wp-customize-themes-section.php       2017-10-18 15:10:19 UTC (rev 41903)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,6 +80,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        <div class="customize-preview-header themes-filter-bar">
</span><span class="cx" style="display: block; padding: 0 10px">                                                <?php $this->filter_bar_content_template(); ?>
</span><span class="cx" style="display: block; padding: 0 10px">                                        </div>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        <# if ( 'wporg' === data.action ) { #>
+                                               <?php $this->filter_drawer_content_template(); ?>
+                                       <# } #>
</ins><span class="cx" style="display: block; padding: 0 10px">                                         <div class="error unexpected-error" style="display: none; "><p><?php _e( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ); ?></p></div>
</span><span class="cx" style="display: block; padding: 0 10px">                                        <ul class="themes">
</span><span class="cx" style="display: block; padding: 0 10px">                                        </ul>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -125,22 +128,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                ?>
</span><span class="cx" style="display: block; padding: 0 10px">                                </span>
</span><span class="cx" style="display: block; padding: 0 10px">                        </button>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <div class="filter-drawer filter-details">
-                               <?php
-                               $feature_list = get_theme_feature_list( false ); // @todo: Use the .org API instead of the local core feature list. The .org API is currently outdated and will be reconciled when the .org themes directory is next redesigned.
-                               foreach ( $feature_list as $feature_name => $features ) {
-                                       echo '<fieldset class="filter-group">';
-                                       echo '<legend>' . esc_html( $feature_name ) . '</legend>';
-                                       echo '<div class="filter-group-feature">';
-                                       foreach ( $features as $feature => $feature_name ) {
-                                               echo '<input type="checkbox" id="filter-id-' . esc_attr( $feature ) . '" value="' . esc_attr( $feature ) . '" /> ';
-                                               echo '<label for="filter-id-' . esc_attr( $feature ) . '">' . esc_html( $feature_name ) . '</label><br>';
-                                       }
-                                       echo '</div>';
-                                       echo '</fieldset>';
-                               }
-                               ?>
-                       </div>
</del><span class="cx" style="display: block; padding: 0 10px">                 <# } else { #>
</span><span class="cx" style="display: block; padding: 0 10px">                        <div class="themes-filter-container">
</span><span class="cx" style="display: block; padding: 0 10px">                                <label for="{{ data.id }}-themes-filter" class="screen-reader-text"><?php _e( 'Search themes&hellip;' ); ?></label>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -159,4 +146,31 @@
</span><span class="cx" style="display: block; padding: 0 10px">                </div>
</span><span class="cx" style="display: block; padding: 0 10px">                <?php
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Render the filter drawer portion of a themes section as a JS template.
+        *
+        * The template is only rendered by PHP once, so all actions are prepared at once on the server side.
+        * The filter bar container is rendered by @see `render_template()`.
+        *
+        * @since 4.9.0
+        */
+       protected function filter_drawer_content_template() {
+               $feature_list = get_theme_feature_list( false ); // @todo: Use the .org API instead of the local core feature list. The .org API is currently outdated and will be reconciled when the .org themes directory is next redesigned.
+               ?>
+               <div class="filter-drawer filter-details">
+                       <?php foreach ( $feature_list as $feature_name => $features ) : ?>
+                               <fieldset class="filter-group">
+                                       <legend><?php echo esc_html( $feature_name ); ?></legend>
+                                       <div class="filter-group-feature">
+                                               <?php foreach ( $features as $feature => $feature_name ) : ?>
+                                                       <input type="checkbox" id="filter-id-<?php echo esc_attr( $feature ); ?>" value="<?php echo esc_attr( $feature ); ?>" />
+                                                       <label for="filter-id-<?php echo esc_attr( $feature ); ?>"><?php echo esc_html( $feature_name ); ?></label><br>
+                                               <?php endforeach; ?>
+                                       </div>
+                               </fieldset>
+                       <?php endforeach; ?>
+               </div>
+               <?php
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>