<!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>[40789] trunk/src/wp-admin: Dashboard:</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/40789">40789</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/40789","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-05-19 04:00:32 +0000 (Fri, 19 May 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'>Dashboard:
- Close the form after obtaining a valid location.
- Fix focusing the toggle button after closing the form.
- Fix aria attribute values.
- Fix positions in IE11.
- Some JS and CSS cleanup.

Props afercia, coreymckrill.
Fixes <a href="https://core.trac.wordpress.org/ticket/40735">#40735</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincssdashboardcss">trunk/src/wp-admin/css/dashboard.css</a></li>
<li><a href="#trunksrcwpadminincludesdashboardphp">trunk/src/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunksrcwpadminjsdashboardjs">trunk/src/wp-admin/js/dashboard.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincssdashboardcss"></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/dashboard.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/dashboard.css      2017-05-19 03:52:07 UTC (rev 40788)
+++ trunk/src/wp-admin/css/dashboard.css        2017-05-19 04:00:32 UTC (rev 40789)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -323,10 +323,10 @@
</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"> .community-events-errors[aria-hidden="true"],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.community-events-errors *[aria-hidden="true"],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.community-events-errors [aria-hidden="true"],
</ins><span class="cx" style="display: block; padding: 0 10px"> .community-events-loading[aria-hidden="true"],
</span><span class="cx" style="display: block; padding: 0 10px"> .community-events[aria-hidden="true"],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.community-events *[aria-hidden="true"] {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.community-events [aria-hidden="true"] {
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -342,16 +342,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> .community-events-form .regular-text {
</span><span class="cx" style="display: block; padding: 0 10px">        width: 40%;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        height: 28px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ height: 29px;
+       margin: 0;
+       vertical-align: top;
</ins><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"> .community-events li.event-none {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        border-left: 4px solid #0070AE;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ border-left: 4px solid #00a0d2;
</ins><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"> .community-events-form label {
</span><span class="cx" style="display: block; padding: 0 10px">        display: inline-block;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        padding-bottom: 3px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ vertical-align: top;
+       line-height: 28px;
+       height: 28px;
</ins><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"> .community-events .activity-block > p {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -359,19 +363,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">        display: inline;
</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">-#community-events-submit {
-       margin-left: 2px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.community-events-toggle-location {
+       vertical-align: middle;
</ins><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">-.community-events .button-link:hover,
-.community-events .button-link:active {
-       color: #00a0d2;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#community-events-submit {
+       margin-left: 3px;
+       margin-right: 3px;
</ins><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">-.community-events-cancel.button.button-link {
-       color: #0073aa;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* Needs higher specificity than #dashboard-widgets .button-link */
+#dashboard-widgets .community-events-cancel.button-link {
+       vertical-align: top;
+       /* Same properties as the submit button for cross-browsers alignment. */
+       line-height: 26px;
+       height: 28px;
</ins><span class="cx" style="display: block; padding: 0 10px">         text-decoration: underline;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        margin-left: 2px;
</del><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"> .community-events ul {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1235,11 +1242,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        .community-events-toggle-location {
</span><span class="cx" style="display: block; padding: 0 10px">                height: 38px;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                vertical-align: baseline;
</ins><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">        .community-events-form .regular-text {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                height: 31px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         height: 32px;
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       #community-events-submit {
+               margin-bottom: 0;
+       }
+
+       .community-events-form label,
+       #dashboard-widgets .community-events-cancel.button-link {
+               /* Same properties as the submit button for cross-browsers alignment. */
+               font-size: 14px;
+               line-height: normal;
+               height: auto;
+               padding: 6px 0;
+               border: 1px solid transparent;
+       }
</ins><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"> /* Smartphone */
</span></span></pre></div>
<a id="trunksrcwpadminincludesdashboardphp"></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/includes/dashboard.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/dashboard.php 2017-05-19 03:52:07 UTC (rev 40788)
+++ trunk/src/wp-admin/includes/dashboard.php   2017-05-19 04:00:32 UTC (rev 40789)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1173,7 +1173,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                <?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                <button class="community-events-cancel button button-link" type="button" aria-expanded="false">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         <button class="community-events-cancel button-link" type="button" aria-expanded="false">
</ins><span class="cx" style="display: block; padding: 0 10px">                                         <?php _e( 'Cancel' ); ?>
</span><span class="cx" style="display: block; padding: 0 10px">                                </button>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpadminjsdashboardjs"></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/dashboard.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/dashboard.js        2017-05-19 03:52:07 UTC (rev 40788)
+++ trunk/src/wp-admin/js/dashboard.js  2017-05-19 04:00:32 UTC (rev 40789)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -191,10 +191,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> jQuery( function( $ ) {
</span><span class="cx" style="display: block; padding: 0 10px">        'use strict';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        
-       var communityEventsData = window.communityEventsData || {};
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        var app = window.wp.communityEvents = {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var communityEventsData = window.communityEventsData || {},
+               app;
+
+       app = window.wp.communityEvents = {
</ins><span class="cx" style="display: block; padding: 0 10px">                 initialized: false,
</span><span class="cx" style="display: block; padding: 0 10px">                model: null,
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -212,7 +213,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">                         * When JavaScript is disabled, the errors container is shown, so
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                         * that "This widget requires Javascript" message can be seen.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                  * that "This widget requires JavaScript" message can be seen.
</ins><span class="cx" style="display: block; padding: 0 10px">                          *
</span><span class="cx" style="display: block; padding: 0 10px">                         * When JS is enabled, the container is hidden at first, and then
</span><span class="cx" style="display: block; padding: 0 10px">                         * revealed during the template rendering, if there actually are
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,7 +228,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                         * message.
</span><span class="cx" style="display: block; padding: 0 10px">                         */
</span><span class="cx" style="display: block; padding: 0 10px">                        $( '.community-events-errors' )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                .attr( 'aria-hidden', true )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         .attr( 'aria-hidden', 'true' )
</ins><span class="cx" style="display: block; padding: 0 10px">                                 .removeClass( 'hide-if-js' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -235,7 +236,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $container.on( 'submit', '.community-events-form', function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                event.preventDefault();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                app.getEvents( {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         app.getEvents({
</ins><span class="cx" style="display: block; padding: 0 10px">                                         location: $( '#community-events-location' ).val()
</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">@@ -255,26 +256,41 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * @since 4.8.0
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param {event|string} action 'show' or 'hide' to specify a state;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 *                              Or an event object to flip between states
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          *                              or an event object to flip between states.
</ins><span class="cx" style="display: block; padding: 0 10px">                  */
</span><span class="cx" style="display: block; padding: 0 10px">                toggleLocationForm: function( action ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        var $toggleButton = $( '.community-events-toggle-location' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            $cancelButton = $( '.community-events-cancel' ),
-                           $form         = $( '.community-events-form' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $cancelButton = $( '.community-events-cancel' ),
+                               $form         = $( '.community-events-form' ),
+                               $target       = $();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( 'object' === typeof action ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // Strict comparison doesn't work in this case.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         // The action is the event object: get the clicked element.
+                               $target = $( action.target );
+                               /*
+                                * Strict comparison doesn't work in this case because sometimes
+                                * we explicitly pass a string as value of aria-expanded and
+                                * sometimes a boolean as the result of an evaluation.
+                                */
</ins><span class="cx" style="display: block; padding: 0 10px">                                 action = 'true' == $toggleButton.attr( 'aria-expanded' ) ? 'hide' : 'show';
</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">                        if ( 'hide' === action ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $toggleButton.attr( 'aria-expanded', false );
-                               $cancelButton.attr( 'aria-expanded', false );
-                               $form.attr( 'aria-hidden', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $toggleButton.attr( 'aria-expanded', 'false' );
+                               $cancelButton.attr( 'aria-expanded', 'false' );
+                               $form.attr( 'aria-hidden', 'true' );
+                               /*
+                                * If the Cancel button has been clicked, bring the focus back
+                                * to the toggle button so users relying on screen readers don't
+                                * lose their place.
+                                */
+                               if ( $target.hasClass( 'community-events-cancel' ) ) {
+                                       $toggleButton.focus();
+                               }
</ins><span class="cx" style="display: block; padding: 0 10px">                         } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $toggleButton.attr( 'aria-expanded', true );
-                               $cancelButton.attr( 'aria-expanded', true );
-                               $form.attr( 'aria-hidden', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $toggleButton.attr( 'aria-expanded', 'true' );
+                               $cancelButton.attr( 'aria-expanded', 'true' );
+                               $form.attr( 'aria-hidden', 'false' );
</ins><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"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -287,8 +303,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                getEvents: function( requestParams ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        var initiatedBy,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            app = this,
-                           $spinner = $( '.community-events-form' ).children( '.spinner' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         app = this,
+                               $spinner = $( '.community-events-form' ).children( '.spinner' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        requestParams          = requestParams || {};
</span><span class="cx" style="display: block; padding: 0 10px">                        requestParams._wpnonce = communityEventsData.nonce;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -314,7 +330,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                         * it should fail silently. Otherwise, the error could confuse and/or
</span><span class="cx" style="display: block; padding: 0 10px">                                                         * annoy them.
</span><span class="cx" style="display: block; padding: 0 10px">                                                         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                                                         delete response.error;
</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">@@ -322,7 +337,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">                                .fail( function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        app.renderEventsTemplate( {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 app.renderEventsTemplate({
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 'location' : false,
</span><span class="cx" style="display: block; padding: 0 10px">                                                'error'    : true
</span><span class="cx" style="display: block; padding: 0 10px">                                        }, initiatedBy );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -334,23 +349,24 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="cx" style="display: block; padding: 0 10px">                 * @since 4.8.0
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 * @param {Object} templateParams The various parameters that will get passed to wp.template
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          * @param {Object} templateParams The various parameters that will get passed to wp.template.
</ins><span class="cx" style="display: block; padding: 0 10px">                  * @param {string} initiatedBy    'user' to indicate that this was triggered manually by the user;
</span><span class="cx" style="display: block; padding: 0 10px">                 *                                'app' to indicate it was triggered automatically by the app itself.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                renderEventsTemplate: function( templateParams, initiatedBy ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        var template,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            elementVisibility,
-                           l10nPlaceholder  = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc.
-                           $locationMessage = $( '#community-events-location-message' ),
-                           $results         = $( '.community-events-results' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         elementVisibility,
+                               l10nPlaceholder  = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc.
+                               $toggleButton    = $( '.community-events-toggle-location' ),
+                               $locationMessage = $( '#community-events-location-message' ),
+                               $results         = $( '.community-events-results' );
</ins><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">                         * Hide all toggleable elements by default, to keep the logic simple.
</span><span class="cx" style="display: block; padding: 0 10px">                         * Otherwise, each block below would have to turn hide everything that
</span><span class="cx" style="display: block; padding: 0 10px">                         * could have been shown at an earlier point.
</span><span class="cx" style="display: block; padding: 0 10px">                         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                         * The exception to that is that the .community-events container. It's hidden
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                  * The exception to that is that the .community-events container is hidden
</ins><span class="cx" style="display: block; padding: 0 10px">                          * when the page is first loaded, because the content isn't ready yet,
</span><span class="cx" style="display: block; padding: 0 10px">                         * but once we've reached this point, it should always be shown.
</span><span class="cx" style="display: block; padding: 0 10px">                         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -380,7 +396,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        template = wp.template( 'community-events-no-upcoming-events' );
</span><span class="cx" style="display: block; padding: 0 10px">                                        $results.html( template( templateParams ) );
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                elementVisibility['#community-events-location-message'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">                                elementVisibility['.community-events-toggle-location']  = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -405,7 +421,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                elementVisibility['.community-events-errors']         = true;
</span><span class="cx" style="display: block; padding: 0 10px">                                elementVisibility['.community-events-error-occurred'] = true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                         } else {
</span><span class="cx" style="display: block; padding: 0 10px">                                $locationMessage.text( communityEventsData.l10n.enter_closest_city );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -418,17 +433,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $( element ).attr( 'aria-hidden', ! isVisible );
</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">-                        $( '.community-events-toggle-location' ).attr( 'aria-expanded', elementVisibility['.community-events-toggle-location'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $toggleButton.attr( 'aria-expanded', elementVisibility['.community-events-toggle-location'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        /*
-                        * During the initial page load, the location form should be hidden
-                        * by default if the user has saved a valid location during a previous
-                        * session. It's safe to assume that they want to continue using that
-                        * location, and displaying the form would unnecessarily clutter the
-                        * widget.
-                        */
-                       if ( 'app' === initiatedBy && templateParams.location ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( templateParams.location ) {
+                               // Hide the form when there's a valid location.
</ins><span class="cx" style="display: block; padding: 0 10px">                                 app.toggleLocationForm( 'hide' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                               if ( 'user' === initiatedBy ) {
+                                       /*
+                                        * When the form is programmatically hidden after a user search,
+                                        * bring the focus back to the toggle button so users relying
+                                        * on screen readers don't lose their place.
+                                        */
+                                       $toggleButton.focus();
+                               }
</ins><span class="cx" style="display: block; padding: 0 10px">                         } else {
</span><span class="cx" style="display: block; padding: 0 10px">                                app.toggleLocationForm( 'show' );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span></span></pre>
</div>
</div>

</body>
</html>