WordPress.org

Make WordPress Core

Ticket #40735: 40735-form-ux.diff

File 40735-form-ux.diff, 1.7 KB (added by coreymckrill, 3 years ago)
  • src/wp-admin/js/dashboard.js

     
    380380                                        template = wp.template( 'community-events-no-upcoming-events' );
    381381                                        $results.html( template( templateParams ) );
    382382                                }
    383                                 wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location ) );
     383                                wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' );
    384384
    385385                                elementVisibility['#community-events-location-message'] = true;
    386386                                elementVisibility['.community-events-toggle-location']  = true;
     
    420420
    421421                        $( '.community-events-toggle-location' ).attr( 'aria-expanded', elementVisibility['.community-events-toggle-location'] );
    422422
    423                         /*
    424                          * During the initial page load, the location form should be hidden
    425                          * by default if the user has saved a valid location during a previous
    426                          * session. It's safe to assume that they want to continue using that
    427                          * location, and displaying the form would unnecessarily clutter the
    428                          * widget.
    429                          */
    430                         if ( 'app' === initiatedBy && templateParams.location ) {
     423                        if ( templateParams.location ) {
     424                                // Hide the form when there's a valid location.
    431425                                app.toggleLocationForm( 'hide' );
     426
     427                                if ( 'user' === initiatedBy ) {
     428                                        // When the form is programmatically hidden after a user search, bring the focus back to the toggle
     429                                        // button so users relying on screen readers don't lose their place.
     430                                        $( '.community-events-toggle-location' ).focus();
     431                                }
    432432                        } else {
    433433                                app.toggleLocationForm( 'show' );
    434434                        }