Skip to content

Commit 1ae1d72

Browse files
lezamalezamaoandregal
authored
DataViews: Keep icon-only buttons on mobile for bulk actions (#72761)
Co-authored-by: lezama <migueluy@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org>
1 parent 64cbf58 commit 1ae1d72

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/dataviews/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Enhancements
66

7+
- DataViews: keep icon-only buttons on mobile for bulk actions. [#72761](https://github.com/WordPress/gutenberg/pull/72761)
78
- DataForm: update spacing for regular and card layouts. [#72249](https://github.com/WordPress/gutenberg/pull/72249).
89
- DataForm: Fix password field suffix alignment. [#72524](https://github.com/WordPress/gutenberg/pull/72524).
910

packages/dataviews/src/components/dataviews-bulk-actions/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { __, sprintf, _n } from '@wordpress/i18n';
1515
import { useMemo, useState, useRef, useContext } from '@wordpress/element';
1616
import { useRegistry } from '@wordpress/data';
1717
import { closeSmall } from '@wordpress/icons';
18+
import { useViewportMatch } from '@wordpress/compose';
1819

1920
/**
2021
* Internal dependencies
@@ -165,6 +166,22 @@ function ActionTrigger< Item >( {
165166
}: ActionTriggerProps< Item > ) {
166167
const label =
167168
typeof action.label === 'string' ? action.label : action.label( items );
169+
const isMobile = useViewportMatch( 'medium', '<' );
170+
171+
if ( isMobile ) {
172+
return (
173+
<Button
174+
disabled={ isBusy }
175+
accessibleWhenDisabled
176+
label={ label }
177+
icon={ action.icon }
178+
size="compact"
179+
onClick={ onClick }
180+
isBusy={ isBusy }
181+
/>
182+
);
183+
}
184+
168185
return (
169186
<Button
170187
disabled={ isBusy }
@@ -308,6 +325,7 @@ function FooterContent< Item >( {
308325
null
309326
);
310327
const footerContentRef = useRef< JSX.Element | null >( null );
328+
const isMobile = useViewportMatch( 'medium', '<' );
311329

312330
const bulkActions = useMemo(
313331
() => actions.filter( ( action ) => action.supportsBulk ),
@@ -334,13 +352,14 @@ function FooterContent< Item >( {
334352
actions.filter( ( action ) => {
335353
return (
336354
action.supportsBulk &&
355+
( ! isMobile || action.icon ) &&
337356
selectedItems.some(
338357
( item ) =>
339358
! action.isEligible || action.isEligible( item )
340359
)
341360
);
342361
} ),
343-
[ actions, selectedItems ]
362+
[ actions, selectedItems, isMobile ]
344363
);
345364
if ( ! actionInProgress ) {
346365
if ( footerContentRef.current ) {

0 commit comments

Comments
 (0)