Make WordPress Core

Changeset 29035


Ignore:
Timestamp:
07/08/2014 08:18:30 PM (10 years ago)
Author:
helen
Message:

Customizer panels:

  • Close all accordion sections when going in and out of panels.
  • Fix panel positioning when top-level Customizer controls are scrolled down.
  • Keyboard accessibility: only focus on visible elements and transfer between them as needed when navigating around panels.

props celloexpressions. see #27406.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/accordion.js

    r28861 r29035  
    7070
    7171    function panelSwitch( panel ) {
    72         var position,
     72        var position, scroll,
    7373            section = panel.closest( '.accordion-section' ),
    74             container = section.closest( '.wp-full-overlay' ),
    75             siblings = container.find( '.accordion-section.open' ),
     74            overlay = section.closest( '.wp-full-overlay' ),
     75            container = section.closest( '.accordion-container' ),
     76            siblings = container.find( '.open' ),
     77            topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ).add( '#customize-info > .accordion-section-title' ),
     78            backBtn = section.find( '.control-panel-back' ),
     79            panelTitle = section.find( '.accordion-section-title' ).first(),
    7680            content = section.find( '.control-panel-content' );
    7781
    7882        if ( section.hasClass( 'current-panel' ) ) {
    7983            section.toggleClass( 'current-panel' );
    80             container.toggleClass( 'in-sub-panel' );
     84            overlay.toggleClass( 'in-sub-panel' );
    8185            content.delay( 180 ).hide( 0, function() {
    8286                content.css( 'margin-top', 'inherit' ); // Reset
    8387            } );
     88            topPanel.attr( 'tabindex', '0' );
     89            backBtn.attr( 'tabindex', '-1' );
     90            panelTitle.focus();
     91            container.scrollTop( 0 );
    8492        } else {
     93            // Close all open sections in any accordion level.
    8594            siblings.removeClass( 'open' );
     95            siblings.find( sectionContent ).show().slideUp( 0 );
    8696            content.show( 0, function() {
    8797                position = content.offset().top;
    88                 content.css( 'margin-top', ( 45 - position ) );
     98                scroll = container.scrollTop();
     99                content.css( 'margin-top', ( 45 - position - scroll ) );
    89100                section.toggleClass( 'current-panel' );
    90                 container.toggleClass( 'in-sub-panel' );
     101                overlay.toggleClass( 'in-sub-panel' );
     102                container.scrollTop( 0 );
    91103            } );
     104            topPanel.attr( 'tabindex', '-1' );
     105            backBtn.attr( 'tabindex', '0' );
     106            backBtn.focus();
    92107        }
    93108    }
  • trunk/src/wp-includes/class-wp-customize-section.php

    r28927 r29035  
    241241        <li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="control-section control-panel accordion-section">
    242242            <h3 class="accordion-section-title" tabindex="0"><?php echo esc_html( $this->title ); ?></h3>
    243             <span class="control-panel-back" tabindex="0"><span class="screen-reader-text">Back to Customize</span></span>
     243            <span class="control-panel-back" tabindex="-1"><span class="screen-reader-text">Back to Customize</span></span>
    244244            <ul class="accordion-sub-container control-panel-content">
    245245                <li class="accordion-section control-section<?php if ( empty( $this->description ) ) echo ' cannot-expand'; ?>">
Note: See TracChangeset for help on using the changeset viewer.