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

Add ability to deselect rows in one click in BulkActionsToolbar #4859

Merged
merged 2 commits into from
May 27, 2020
Merged
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
4 changes: 2 additions & 2 deletions cypress/support/ListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export default url => ({
logout: '.logout',
bulkActionsToolbar: '[data-test=bulk-actions-toolbar]',
customBulkActionsButton:
'[data-test=bulk-actions-toolbar] button:first-child',
'[data-test=bulk-actions-toolbar] button[aria-label="Reset views"]',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Better but it would even better to not rely on those css selectors at all, just as users do. This is something we should fix in a pr dedicated to e2e tests though

deleteBulkActionsButton:
'[data-test=bulk-actions-toolbar] button:nth-child(2)',
'[data-test=bulk-actions-toolbar] button[aria-label="Delete"]',
selectAll: '.select-all',
selectedItem: '.select-item input:checked',
selectItem: '.select-item input',
Expand Down
1 change: 1 addition & 0 deletions packages/ra-language-english/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const englishMessages: TranslationMessages = {
show: 'Show',
sort: 'Sort',
undo: 'Undo',
unselect: 'Unselect',
expand: 'Expand',
close: 'Close',
open_menu: 'Open menu',
Expand Down
1 change: 1 addition & 0 deletions packages/ra-language-french/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const frenchMessages: TranslationMessages = {
show: 'Afficher',
sort: 'Trier',
undo: 'Annuler',
unselect: 'Désélectionner',
expand: 'Étendre',
close: 'Fermer',
open_menu: 'Ouvrir le menu',
Expand Down
17 changes: 17 additions & 0 deletions packages/ra-ui-materialui/src/list/BulkActionsToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import { lighten } from '@material-ui/core/styles/colorManipulator';
import IconButton from '@material-ui/core/IconButton';
import CloseIcon from '@material-ui/icons/Close';
import { useTranslate, sanitizeListRestProps } from 'ra-core';

import TopToolbar from '../layout/TopToolbar';
Expand Down Expand Up @@ -35,8 +37,13 @@ const useStyles = makeStyles(
overflowY: 'hidden',
},
title: {
display: 'flex',
flex: '0 0 auto',
},
icon: {
marginLeft: '-0.5em',
marginRight: '0.5em',
},
}),
{ name: 'RaBulkActionsToolbar' }
);
Expand All @@ -49,6 +56,7 @@ const BulkActionsToolbar = props => {
label,
resource,
selectedIds,
onUnselectItems,
children,
...rest
} = props;
Expand All @@ -64,6 +72,15 @@ const BulkActionsToolbar = props => {
{...sanitizeListRestProps(rest)}
>
<div className={classes.title}>
<IconButton
className={classes.icon}
aria-label={translate('ra.action.unselect')}
title={translate('ra.action.unselect')}
onClick={onUnselectItems}
size="small"
>
<CloseIcon fontSize="small" />
</IconButton>
<Typography color="inherit" variant="subtitle1">
{translate(label, {
_: label,
Expand Down