-
From 8894171c45766b8d733b8f8421094ad50f635974 Mon Sep 17 00:00:00 2001
From: Ryan Kienstra <ryan.kienstra@xwp.co>
Date: Fri, 4 Mar 2016 01:48:11 -0300
Subject: [PATCH 1/9] Customize : Remove extra space at bottom of Customizer
panel.
Before, non-active sections and panels still occupied space in the DOM.
So the active panel had a 'margin-top' property to move it to the top.
So set the height of the non-active sections to 0.
And don't add a margin-top value to the active panel's content.
Fixes #35947.
---
src/wp-admin/css/customize-controls.css | 8 ++++++++
src/wp-admin/js/customize-controls.js | 1 -
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
index 82132e3..32d5827 100644
a
|
b
|
h3.customize-section-title { |
430 | 430 | width: 300px; |
431 | 431 | } |
432 | 432 | |
| 433 | .in-sub-panel #customize-info { |
| 434 | height: 0; |
| 435 | } |
| 436 | |
| 437 | .in-sub-panel #customize-theme-controls > ul > .control-section:not(.current-panel) { |
| 438 | height: 0; |
| 439 | } |
| 440 | |
433 | 441 | .in-sub-panel #customize-theme-controls .accordion-section.current-panel { |
434 | 442 | width: 100%; |
435 | 443 | } |
-
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
index 8fcf08b..1c1acfd 100644
a
|
b
|
|
1363 | 1363 | content.parent().show(); |
1364 | 1364 | position = content.offset().top; |
1365 | 1365 | scroll = container.scrollTop(); |
1366 | | content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); |
1367 | 1366 | accordionSection.addClass( 'current-panel' ); |
1368 | 1367 | overlay.addClass( 'in-sub-panel' ); |
1369 | 1368 | container.scrollTop( 0 ); |
-
From 200b497d271bedc324f21262465487210164433e Mon Sep 17 00:00:00 2001
From: Ryan Kienstra <ryan.kienstra@xwp.co>
Date: Fri, 4 Mar 2016 02:16:23 -0300
Subject: [PATCH 2/9] Customize : Remove variables that were deleted in commit
8894171.
These are no longer used in the function in which they're defined.
They were deleted as part of a commit to remove the 'margin-top' value.
Fixes #35947.
---
src/wp-admin/js/customize-controls.js | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
index 1c1acfd..086472b 100644
a
|
b
|
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | // Note: there is a second argument 'args' passed |
1336 | | var position, scroll, |
1337 | | panel = this, |
| 1336 | var panel = this, |
1338 | 1337 | accordionSection = panel.container.closest( '.accordion-section' ), |
1339 | 1338 | overlay = accordionSection.closest( '.wp-full-overlay' ), |
1340 | 1339 | container = accordionSection.closest( '.wp-full-overlay-sidebar-content' ), |
… |
… |
|
1342 | 1341 | topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ), |
1343 | 1342 | backBtn = accordionSection.find( '.customize-panel-back' ), |
1344 | 1343 | panelTitle = accordionSection.find( '.accordion-section-title' ).first(), |
1345 | | content = accordionSection.find( '.control-panel-content' ), |
1346 | | headerActionsHeight = $( '#customize-header-actions' ).height(); |
| 1344 | content = accordionSection.find( '.control-panel-content' ); |
1347 | 1345 | |
1348 | 1346 | if ( expanded ) { |
1349 | 1347 | |
… |
… |
|
1361 | 1359 | |
1362 | 1360 | content.show( 0, function() { |
1363 | 1361 | content.parent().show(); |
1364 | | position = content.offset().top; |
1365 | | scroll = container.scrollTop(); |
1366 | 1362 | accordionSection.addClass( 'current-panel' ); |
1367 | 1363 | overlay.addClass( 'in-sub-panel' ); |
1368 | 1364 | container.scrollTop( 0 ); |
-
From c00e5eaf37284881a363aecefcc4b06e636ca1ba Mon Sep 17 00:00:00 2001
From: Ryan Kienstra <ryan.kienstra@xwp.co>
Date: Sat, 5 Mar 2016 01:00:12 -0300
Subject: [PATCH 3/9] Fix issue with widget's contents being too high on
clicking in preview.
When clicking a widget in the preview, the 'onChangeExpanded' method is called.
This included a jQuery method that adds a 'margin-top' value.
Remove this method call, as it caused a spacing issue.
The inactive panels no longer occupy space, from commit 8894171c.
So there's no adjustment needed for the controls to appear properly.
Fixes #34747.
---
src/wp-admin/js/customize-controls.js | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
index 086472b..7fd2b54 100644
a
|
b
|
|
648 | 648 | overlay = section.container.closest( '.wp-full-overlay' ), |
649 | 649 | backBtn = section.container.find( '.customize-section-back' ), |
650 | 650 | sectionTitle = section.container.find( '.accordion-section-title' ).first(), |
651 | | headerActionsHeight = $( '#customize-header-actions' ).height(), |
652 | | resizeContentHeight, expand, position, scroll; |
| 651 | resizeContentHeight, expand; |
653 | 652 | |
654 | 653 | if ( expanded && ! section.container.hasClass( 'open' ) ) { |
655 | 654 | |
… |
… |
|
671 | 670 | expand = function() { |
672 | 671 | section.container.addClass( 'open' ); |
673 | 672 | overlay.addClass( 'section-open' ); |
674 | | position = content.offset().top; |
675 | | scroll = container.scrollTop(); |
676 | | content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); |
677 | 673 | resizeContentHeight(); |
678 | 674 | sectionTitle.attr( 'tabindex', '-1' ); |
679 | 675 | backBtn.attr( 'tabindex', '0' ); |
-
From 334473cb0975541e7b46935caa50061ec235fd45 Mon Sep 17 00:00:00 2001
From: Piotr Delawski <piotr.delawski@xwp.co>
Date: Sat, 5 Mar 2016 16:44:44 +0100
Subject: [PATCH 4/9] Remove horizontal gap next to scrollbar when opening a
panel (reverts previous changes by @kienstra).
---
src/wp-admin/css/customize-controls.css | 8 --------
src/wp-admin/js/customize-controls.js | 27 ++++++++++++++++++---------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
index 32d5827..82132e3 100644
a
|
b
|
h3.customize-section-title { |
430 | 430 | width: 300px; |
431 | 431 | } |
432 | 432 | |
433 | | .in-sub-panel #customize-info { |
434 | | height: 0; |
435 | | } |
436 | | |
437 | | .in-sub-panel #customize-theme-controls > ul > .control-section:not(.current-panel) { |
438 | | height: 0; |
439 | | } |
440 | | |
441 | 433 | .in-sub-panel #customize-theme-controls .accordion-section.current-panel { |
442 | 434 | width: 100%; |
443 | 435 | } |
-
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
index 7fd2b54..3a89bb7 100644
a
|
b
|
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | // Note: there is a second argument 'args' passed |
1332 | | var panel = this, |
| 1332 | var position, scroll, |
| 1333 | panel = this, |
1333 | 1334 | accordionSection = panel.container.closest( '.accordion-section' ), |
1334 | 1335 | overlay = accordionSection.closest( '.wp-full-overlay' ), |
1335 | 1336 | container = accordionSection.closest( '.wp-full-overlay-sidebar-content' ), |
… |
… |
|
1337 | 1338 | topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ), |
1338 | 1339 | backBtn = accordionSection.find( '.customize-panel-back' ), |
1339 | 1340 | panelTitle = accordionSection.find( '.accordion-section-title' ).first(), |
1340 | | content = accordionSection.find( '.control-panel-content' ); |
| 1341 | content = accordionSection.find( '.control-panel-content' ), |
| 1342 | headerActionsHeight = $( '#customize-header-actions' ).height(); |
1341 | 1343 | |
1342 | 1344 | if ( expanded ) { |
1343 | 1345 | |
… |
… |
|
1355 | 1357 | |
1356 | 1358 | content.show( 0, function() { |
1357 | 1359 | content.parent().show(); |
| 1360 | position = content.offset().top; |
| 1361 | scroll = container.scrollTop(); |
| 1362 | content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); |
1358 | 1363 | accordionSection.addClass( 'current-panel' ); |
1359 | 1364 | overlay.addClass( 'in-sub-panel' ); |
1360 | 1365 | container.scrollTop( 0 ); |
1361 | | if ( args.completeCallback ) { |
1362 | | args.completeCallback(); |
1363 | | } |
| 1366 | _.defer( function() { |
| 1367 | panel._recalculateTopMargin(); |
| 1368 | topPanel.attr( 'tabindex', '-1' ); |
| 1369 | backBtn.attr( 'tabindex', '0' ); |
| 1370 | }); |
| 1371 | _.delay( function() { |
| 1372 | backBtn.focus(); |
| 1373 | if ( args.completeCallback ) { |
| 1374 | args.completeCallback(); |
| 1375 | } |
| 1376 | }, 180 ); |
1364 | 1377 | } ); |
1365 | | topPanel.attr( 'tabindex', '-1' ); |
1366 | | backBtn.attr( 'tabindex', '0' ); |
1367 | | backBtn.focus(); |
1368 | | panel._recalculateTopMargin(); |
1369 | 1378 | } else { |
1370 | 1379 | siblings.removeClass( 'open' ); |
1371 | 1380 | accordionSection.removeClass( 'current-panel' ); |
-
From f0266c082fee227cf81c7d8c775e68449fe7102b Mon Sep 17 00:00:00 2001
From: Piotr Delawski <piotr.delawski@xwp.co>
Date: Sat, 5 Mar 2016 16:58:51 +0100
Subject: [PATCH 5/9] Revert c00e5ea and remove `_.defer` as it seems not be
needed now.
---
src/wp-admin/js/customize-controls.js | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
index b945ce2..dbda12b 100644
a
|
b
|
|
648 | 648 | overlay = section.container.closest( '.wp-full-overlay' ), |
649 | 649 | backBtn = section.container.find( '.customize-section-back' ), |
650 | 650 | sectionTitle = section.container.find( '.accordion-section-title' ).first(), |
651 | | resizeContentHeight, expand; |
| 651 | headerActionsHeight = $( '#customize-header-actions' ).height(), |
| 652 | resizeContentHeight, expand, position, scroll; |
652 | 653 | |
653 | 654 | if ( expanded && ! section.container.hasClass( 'open' ) ) { |
654 | 655 | |
… |
… |
|
670 | 671 | expand = function() { |
671 | 672 | section.container.addClass( 'open' ); |
672 | 673 | overlay.addClass( 'section-open' ); |
| 674 | position = content.offset().top; |
| 675 | scroll = container.scrollTop(); |
| 676 | content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); |
673 | 677 | resizeContentHeight(); |
674 | 678 | sectionTitle.attr( 'tabindex', '-1' ); |
675 | 679 | backBtn.attr( 'tabindex', '0' ); |
… |
… |
|
1363 | 1367 | accordionSection.addClass( 'current-panel' ); |
1364 | 1368 | overlay.addClass( 'in-sub-panel' ); |
1365 | 1369 | container.scrollTop( 0 ); |
1366 | | _.defer( function() { |
1367 | | panel._recalculateTopMargin(); |
1368 | | topPanel.attr( 'tabindex', '-1' ); |
1369 | | backBtn.attr( 'tabindex', '0' ); |
1370 | | }); |
| 1370 | topPanel.attr( 'tabindex', '-1' ); |
| 1371 | backBtn.attr( 'tabindex', '0' ); |
| 1372 | panel._recalculateTopMargin(); |
1371 | 1373 | _.delay( function() { |
1372 | 1374 | backBtn.focus(); |
1373 | 1375 | if ( args.completeCallback ) { |
-
From 89591f9e3c3ae42b6b1c40b350f30c51c90892fa Mon Sep 17 00:00:00 2001
From: Piotr Delawski <piotr.delawski@xwp.co>
Date: Sun, 6 Mar 2016 22:44:00 +0100
Subject: [PATCH 6/9] Remove vertical gap below list of panels when there is a
lot of panels registered.
---
src/wp-admin/css/customize-controls.css | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
index c3b6e01..84e29f3 100644
a
|
b
|
h3.customize-section-title { |
428 | 428 | .in-sub-panel #customize-theme-controls > ul > .accordion-section { |
429 | 429 | left: -300px; |
430 | 430 | width: 300px; |
| 431 | height: 0; |
431 | 432 | } |
432 | 433 | |
433 | 434 | .in-sub-panel #customize-theme-controls .accordion-section.current-panel { |
434 | 435 | width: 100%; |
| 436 | height: auto; |
435 | 437 | } |
436 | 438 | |
437 | 439 | #customize-theme-controls .control-section.current-panel { |
-
From b474bddd16a29b5b0b499a10d00028cce0da1052 Mon Sep 17 00:00:00 2001
From: Ryan Kienstra <ryan.kienstra@xwp.co>
Date: Mon, 7 Mar 2016 04:48:22 -0300
Subject: [PATCH 7/9] Customize : Set height to 0 for all sections in root
panel that aren't open.
Before, non-open sections still took up space in the DOM.
And they caused problems with the calculation of the margin-top value.
So set height to 0 for all sections, and auto for open section.
Fixes #34344.
---
src/wp-admin/css/customize-controls.css | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
index 84e29f3..90e006a 100644
a
|
b
|
h3.customize-section-title { |
461 | 461 | overflow-y: hidden; |
462 | 462 | } |
463 | 463 | |
| 464 | .wp-full-overlay.section-open #customize-theme-controls > ul > .accordion-section { |
| 465 | height: 0; |
| 466 | } |
| 467 | |
| 468 | .wp-full-overlay.section-open #customize-theme-controls > ul > .accordion-section.open { |
| 469 | height: auto; |
| 470 | } |
| 471 | |
464 | 472 | .wp-full-overlay.section-open .wp-full-overlay-sidebar-content .accordion-section.open { |
465 | 473 | visibility: visible; |
466 | 474 | } |
-
From 81b7b76a7c0b6d9bf4e5ee7482efa66cd6cca554 Mon Sep 17 00:00:00 2001
From: Piotr Delawski <piotr.delawski@xwp.co>
Date: Thu, 10 Mar 2016 14:48:05 +0100
Subject: [PATCH 8/9] Fix `focus()` inside widget customize control (try to
focus on form elements first, then on anchors and other elements).
---
src/wp-admin/js/customize-controls.js | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
index dbda12b..9be6b2b 100644
a
|
b
|
|
81 | 81 | construct = this; |
82 | 82 | params = params || {}; |
83 | 83 | focus = function () { |
84 | | var focusContainer; |
| 84 | var focusContainer, focusElement; |
85 | 85 | if ( construct.extended( api.Panel ) && construct.expanded && construct.expanded() ) { |
86 | 86 | focusContainer = construct.container.find( 'ul.control-panel-content' ); |
87 | 87 | } else if ( construct.extended( api.Section ) && construct.expanded && construct.expanded() ) { |
… |
… |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583 |
94 | | focusContainer.find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ).first().focus(); |
| 94 | focusElement = focusContainer.find( 'input, select, textarea, button' ).filter( ':visible' ).first(); |
| 95 | // Focus on objects, links and other element only if no form element/input was found |
| 96 | if ( 0 === focusElement.length ) { |
| 97 | focusElement = focusContainer.find( 'object, a[href], [tabindex]' ).filter( ':visible' ).first(); |
| 98 | } |
| 99 | focusElement.focus(); |
| 100 | |
95 | 101 | }; |
96 | 102 | if ( params.completeCallback ) { |
97 | 103 | completeCallback = params.completeCallback; |
-
From 7f607e7c0882ab155cff072ec6b6c7ebd309c962 Mon Sep 17 00:00:00 2001
From: Piotr Delawski <piotr.delawski@xwp.co>
Date: Sat, 19 Mar 2016 12:26:09 +0100
Subject: [PATCH 9/9] Try to refocus with delay on nav control in case no
element was :visible initially (edge-case scenario; see #35947).
---
src/wp-admin/js/customize-nav-menus.js | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/wp-admin/js/customize-nav-menus.js b/src/wp-admin/js/customize-nav-menus.js
index cad39c6..c8e95b3 100644
a
|
b
|
|
1473 | 1473 | control.expandControlSection(); |
1474 | 1474 | |
1475 | 1475 | params.completeCallback = function() { |
1476 | | var focusable; |
| 1476 | var tryFocus; |
| 1477 | |
| 1478 | tryFocus = function() { |
| 1479 | var focusable; |
| 1480 | |
| 1481 | // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583 |
| 1482 | focusable = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ); |
| 1483 | |
| 1484 | if ( 0 === focusable.length ) { |
| 1485 | return false; |
| 1486 | } |
| 1487 | |
| 1488 | focusable.first().focus(); |
1477 | 1489 | |
1478 | | // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583 |
1479 | | focusable = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ); |
1480 | | focusable.first().focus(); |
| 1490 | if ( originalCompleteCallback ) { |
| 1491 | originalCompleteCallback(); |
| 1492 | } |
| 1493 | |
| 1494 | return true; |
| 1495 | }; |
1481 | 1496 | |
1482 | | if ( originalCompleteCallback ) { |
1483 | | originalCompleteCallback(); |
| 1497 | if ( ! tryFocus() ) { |
| 1498 | _.delay( tryFocus, 180 ); |
1484 | 1499 | } |
1485 | 1500 | }; |
1486 | 1501 | |