fix: discard on mobile (#1107)

This commit is contained in:
Daniel Lautzenheiser
2024-04-26 11:15:28 -04:00
committed by GitHub
parent 79a6fc5a2e
commit 69fc27ab6b
2 changed files with 30 additions and 4 deletions

View File

@ -22,6 +22,11 @@
lg:!hidden; lg:!hidden;
} }
.CMS_EditorToolbar_discard-button {
@apply flex
lg:!hidden;
}
.CMS_EditorToolbar_delete-button { .CMS_EditorToolbar_delete-button {
@apply flex @apply flex
lg:!hidden; lg:!hidden;

View File

@ -29,8 +29,8 @@ import MenuGroup from '../common/menu/MenuGroup';
import MenuItemButton from '../common/menu/MenuItemButton'; import MenuItemButton from '../common/menu/MenuItemButton';
import EditorWorkflowToolbarButtons from './EditorWorkflowToolbarButtons'; import EditorWorkflowToolbarButtons from './EditorWorkflowToolbarButtons';
import type { WorkflowStatus } from '@staticcms/core/constants/publishModes';
import type { CollectionWithDefaults, EditorPersistOptions } from '@staticcms/core'; import type { CollectionWithDefaults, EditorPersistOptions } from '@staticcms/core';
import type { WorkflowStatus } from '@staticcms/core/constants/publishModes';
import type { FC, MouseEventHandler } from 'react'; import type { FC, MouseEventHandler } from 'react';
import './EditorToolbar.css'; import './EditorToolbar.css';
@ -41,6 +41,7 @@ export const classes = generateClassNames('EditorToolbar', [
'more-menu-button', 'more-menu-button',
'more-menu-label-icon', 'more-menu-label-icon',
'preview-toggle', 'preview-toggle',
'discard-button',
'delete-button', 'delete-button',
'publish-button', 'publish-button',
'publish-button-icon', 'publish-button-icon',
@ -419,14 +420,34 @@ const EditorToolbar: FC<EditorToolbarProps> = ({
disabled={disabled} disabled={disabled}
/> />
) : null} ) : null}
{canDelete ? ( {hasChanged ? (
<IconButton
icon={TrashIcon}
key="discard-button"
title={t('editor.editorToolbar.discardChanges')}
color="warning"
variant="text"
onClick={handleDiscardDraft}
rootClassName={classes['discard-button']}
aria-label="discard chnages"
disabled={disabled}
/>
) : canDelete &&
(!useOpenAuthoring || hasUnpublishedChanges) &&
(!useWorkflow || workflowDeleteLabel) ? (
<IconButton <IconButton
icon={TrashIcon} icon={TrashIcon}
key="delete-button" key="delete-button"
title={t('editor.editorToolbar.deleteEntry')} title={useWorkflow ? t(workflowDeleteLabel!) : t('editor.editorToolbar.deleteEntry')}
color="error" color="error"
variant="text" variant="text"
onClick={onDelete} onClick={
useWorkflow &&
workflowDeleteLabel &&
workflowDeleteLabel !== 'editor.editorToolbar.deletePublishedEntry'
? onDeleteUnpublishedChanges
: onDelete
}
rootClassName={classes['delete-button']} rootClassName={classes['delete-button']}
aria-label="delete" aria-label="delete"
disabled={disabled} disabled={disabled}