Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 14 additions & 27 deletions src/js/_enqueues/admin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,32 +874,17 @@ $( function() {
* @return {void}
*/
$( '#collapse-button' ).on( 'click.collapse-menu', function() {
var viewportWidth = getViewportWidth() || 961;

// Reset any compensation for submenus near the bottom of the screen.
$('#adminmenu div.wp-submenu').css('margin-top', '');

if ( viewportWidth <= 960 ) {
if ( $body.hasClass('auto-fold') ) {
$body.removeClass('auto-fold').removeClass('folded');
setUserSetting('unfold', 1);
setUserSetting('mfold', 'o');
menuState = 'open';
} else {
$body.addClass('auto-fold');
setUserSetting('unfold', 0);
menuState = 'folded';
}
if ( $body.hasClass('folded') ) {
$body.removeClass('folded');
setUserSetting('mfold', 'o');
menuState = 'open';
} else {
if ( $body.hasClass('folded') ) {
$body.removeClass('folded');
setUserSetting('mfold', 'o');
menuState = 'open';
} else {
$body.addClass('folded');
setUserSetting('mfold', 'f');
menuState = 'folded';
}
$body.addClass('folded');
setUserSetting('mfold', 'f');
menuState = 'folded';
}

$document.trigger( 'wp-collapse-menu', { state: menuState } );
Expand Down Expand Up @@ -1886,9 +1871,11 @@ $( function() {
* Changes properties of body and admin menu.
*
* Pins and unpins the menu and adds the auto-fold class to the body.
* Makes the admin menu responsive and disables the metabox sortables.
* Makes the admin menu responsive and disables the metabox sortables
* when the viewport is narrow enough.
*
* @since 3.8.0
* @since 7.2.0 Metabox sortables are only disabled at 782px and below.
*
* @return {void}
*/
Expand All @@ -1900,7 +1887,7 @@ $( function() {
}

$adminmenu.data( 'wp-responsive', 1 );
this.disableSortables();
this.maybeDisableSortables();
},

/**
Expand Down Expand Up @@ -1963,7 +1950,7 @@ $( function() {
return;
}

if ( viewportWidth <= 782 ) {
if ( viewportWidth <= 960 ) {
if ( ! wpResponsiveActive ) {
$document.trigger( 'wp-responsive-activate' );
wpResponsiveActive = true;
Expand Down Expand Up @@ -2099,9 +2086,9 @@ $( function() {
function setMenuState() {
var viewportWidth = getViewportWidth() || 961;

if ( viewportWidth <= 782 ) {
if ( viewportWidth <= 960 ) {
menuState = 'responsive';
} else if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && viewportWidth <= 960 && viewportWidth > 782 ) ) {
} else if ( $body.hasClass( 'folded' ) ) {
menuState = 'folded';
} else {
menuState = 'open';
Expand Down
9 changes: 6 additions & 3 deletions src/wp-admin/admin-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ function addLoadEvent( func ) {
$admin_body_class .= ' folded';
}

if ( ! get_user_setting( 'unfold' ) ) {
$admin_body_class .= ' auto-fold';
}
/*
* The admin menu no longer folds automatically. The `auto-fold` class is kept
* because it scopes the responsive admin menu styles and is relied on by
* plugins and the block editor.
*/
$admin_body_class .= ' auto-fold';

if ( is_admin_bar_showing() ) {
$admin_body_class .= ' admin-bar';
Expand Down
74 changes: 33 additions & 41 deletions src/wp-admin/css/admin-menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,16 @@ li#wp-admin-bar-menu-toggle {
display: none;
}

/* Auto-folding of the admin menu */
/*
* Responsive admin menu.
*
* The `auto-fold` body class is always present and is used here to scope the
* responsive menu styles. Below 961px the admin menu is hidden behind the
* toolbar menu toggle instead of being automatically folded.
*/
@media only screen and (max-width: 960px) {
.auto-fold #wpcontent,
.auto-fold #wpfooter {
margin-left: 36px;
}

.auto-fold #adminmenuback,
.auto-fold #adminmenuwrap,
.auto-fold #adminmenu,
.auto-fold #adminmenu li.menu-top {
width: 36px;
#collapse-menu {
display: none;
}

.auto-fold #adminmenu .wp-submenu.sub-open,
Expand Down Expand Up @@ -636,27 +634,10 @@ li#wp-admin-bar-menu-toggle {
z-index: 10000;
}

.auto-fold #collapse-menu .collapse-button-label {
display: none;
}

/* rtl:ignore */
.auto-fold #collapse-button .collapse-button-icon::after {
transform: rotate(180deg);
}

.rtl.auto-fold #collapse-button .collapse-button-icon::after {
transform: none;
}

}

@media screen and (max-width: 782px) {
.auto-fold #wpcontent,
.auto-fold #wpfooter {
position: relative;
margin-left: 0;
padding-left: 10px;
}

.sticky-menu #adminmenuwrap {
Expand Down Expand Up @@ -772,6 +753,30 @@ li#wp-admin-bar-menu-toggle {
}

/* Toolbar menu toggle */
li#wp-admin-bar-menu-toggle {
display: block;
}

#wpadminbar #wp-admin-bar-menu-toggle .ab-icon::before {
content: "\f228";
}

.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #2c3338;
}

.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon::before {
color: #72aee6;
}
}

@media screen and (max-width: 782px) {
.auto-fold #wpcontent,
.auto-fold #wpfooter {
padding-left: 10px;
}

/* Toolbar menu toggle, sized for the taller touch toolbar. */
#wp-responsive-toggle {
position: fixed;
top: 5px;
Expand All @@ -794,20 +799,11 @@ li#wp-admin-bar-menu-toggle {
margin-left: -1px;
}

.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #2c3338;
}

li#wp-admin-bar-menu-toggle {
display: block;
}

#wpadminbar #wp-admin-bar-menu-toggle a:hover {
border: 1px solid transparent;
}

#wpadminbar #wp-admin-bar-menu-toggle .ab-icon::before {
content: "\f228";
display: inline-block;
float: left;
font: 400 40px/45px dashicons;
Expand All @@ -824,10 +820,6 @@ li#wp-admin-bar-menu-toggle {
text-decoration: none;
box-sizing: border-box;
}

.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon::before {
color: #72aee6;
}
}

/* Smartphone */
Expand Down
Loading