Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tools dropdown menu from medium viewport when text labels mode is active #31431

Merged
merged 1 commit into from
May 4, 2021
Merged
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
60 changes: 1 addition & 59 deletions packages/edit-post/src/components/header/header-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ import {
EditorHistoryRedo,
EditorHistoryUndo,
} from '@wordpress/editor';
import {
Button,
DropdownMenu,
ToolbarItem,
MenuItemsChoice,
MenuGroup,
} from '@wordpress/components';
import { Button, ToolbarItem } from '@wordpress/components';
import { plus } from '@wordpress/icons';
import { useRef } from '@wordpress/element';

Expand All @@ -47,7 +41,6 @@ function HeaderToolbar() {
isTextModeEnabled,
previewDeviceType,
showIconLabels,
isNavigationTool,
isTemplateMode,
} = useSelect( ( select ) => {
const {
Expand Down Expand Up @@ -76,14 +69,11 @@ function HeaderToolbar() {
showIconLabels: select( editPostStore ).isFeatureActive(
'showIconLabels'
),
isNavigationTool: select( blockEditorStore ).isNavigationMode(),
isTemplateMode: select( editPostStore ).isEditingTemplate(),
};
}, [] );
const isLargeViewport = useViewportMatch( 'medium' );
const isWideViewport = useViewportMatch( 'wide' );
const isSmallViewport = useViewportMatch( 'small', '<' );
const { setNavigationMode } = useDispatch( blockEditorStore );

const displayBlockToolbar =
! isLargeViewport || previewDeviceType !== 'Desktop' || hasFixedToolbar;
Expand All @@ -94,10 +84,6 @@ function HeaderToolbar() {
: /* translators: accessibility text for the editor toolbar when Top Toolbar is off */
__( 'Document tools' );

const onSwitchMode = ( mode ) => {
setNavigationMode( mode === 'edit' ? false : true );
};

const overflowItems = (
<>
<ToolbarItem
Expand Down Expand Up @@ -174,50 +160,6 @@ function HeaderToolbar() {
{ overflowItems }
</>
) }
{ ! isWideViewport && ! isSmallViewport && showIconLabels && (
<DropdownMenu
position="bottom right"
label={
/* translators: button label text should, if possible, be under 16
characters. */
__( 'Tools' )
}
>
{ () => (
<div className="edit-post-header__dropdown">
<MenuGroup label={ __( 'Modes' ) }>
<MenuItemsChoice
value={
isNavigationTool ? 'select' : 'edit'
}
onSelect={ onSwitchMode }
choices={ [
{
value: 'edit',
label: __( 'Edit' ),
},
{
value: 'select',
label: __( 'Select' ),
},
] }
/>
</MenuGroup>
<MenuGroup label={ __( 'Edit' ) }>
<EditorHistoryUndo
showTooltip={ ! showIconLabels }
isTertiary={ showIconLabels }
/>
<EditorHistoryRedo
showTooltip={ ! showIconLabels }
isTertiary={ showIconLabels }
/>
</MenuGroup>
<MenuGroup>{ overflowItems }</MenuGroup>
</div>
) }
</DropdownMenu>
) }
</div>

<TemplateTitle />
Expand Down