Skip to content

Commit f42b1e1

Browse files
fix: could not save selection from upload has many drawer (#9325)
### What? Could not finalize selection of `hasMany` uploads inside of the drawer. ### Why? The Select component was not being rendered in the beforeActions prop of the ListControls when row selections was enabled. ### How? Renders the Select component when row selections are enabled and onBulkSelect is present.
1 parent bb4f69f commit f42b1e1

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/ui/src/views/List/index.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Pagination } from '../../elements/Pagination/index.js'
2424
import { PerPage } from '../../elements/PerPage/index.js'
2525
import { PublishMany } from '../../elements/PublishMany/index.js'
2626
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'
27+
import { SelectMany } from '../../elements/SelectMany/index.js'
2728
import { useStepNav } from '../../elements/StepNav/index.js'
2829
import { RelationshipProvider } from '../../elements/Table/RelationshipProvider/index.js'
2930
import { TableColumnsProvider } from '../../elements/TableColumns/index.js'
@@ -36,8 +37,8 @@ import { useListQuery } from '../../providers/ListQuery/index.js'
3637
import { SelectionProvider } from '../../providers/Selection/index.js'
3738
import { useTranslation } from '../../providers/Translation/index.js'
3839
import { useWindowInfo } from '../../providers/WindowInfo/index.js'
39-
import './index.scss'
4040
import { ListHeader } from './ListHeader/index.js'
41+
import './index.scss'
4142

4243
const baseClass = 'collection-list'
4344
const Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default
@@ -88,7 +89,7 @@ export const DefaultListView: React.FC<ListViewClientProps> = (props) => {
8889

8990
const [Table, setTable] = useState(InitialTable)
9091

91-
const { createNewDrawerSlug, drawerSlug: listDrawerSlug } = useListDrawerContext()
92+
const { createNewDrawerSlug, drawerSlug: listDrawerSlug, onBulkSelect } = useListDrawerContext()
9293

9394
useEffect(() => {
9495
if (InitialTable) {
@@ -197,7 +198,13 @@ export const DefaultListView: React.FC<ListViewClientProps> = (props) => {
197198
t={t}
198199
/>
199200
<ListControls
200-
beforeActions={beforeActions}
201+
beforeActions={
202+
enableRowSelections && typeof onBulkSelect === 'function'
203+
? beforeActions
204+
? [...beforeActions, <SelectMany key="select-many" onClick={onBulkSelect} />]
205+
: [<SelectMany key="select-many" onClick={onBulkSelect} />]
206+
: beforeActions
207+
}
201208
collectionConfig={collectionConfig}
202209
collectionSlug={collectionSlug}
203210
disableBulkDelete={disableBulkDelete}
@@ -265,7 +272,14 @@ export const DefaultListView: React.FC<ListViewClientProps> = (props) => {
265272
label={getTranslation(collectionConfig.labels.plural, i18n)}
266273
/>
267274
<div className={`${baseClass}__list-selection-actions`}>
268-
{beforeActions && beforeActions}
275+
{enableRowSelections && typeof onBulkSelect === 'function'
276+
? beforeActions
277+
? [
278+
...beforeActions,
279+
<SelectMany key="select-many" onClick={onBulkSelect} />,
280+
]
281+
: [<SelectMany key="select-many" onClick={onBulkSelect} />]
282+
: beforeActions}
269283
{!disableBulkEdit && (
270284
<Fragment>
271285
<EditMany collection={collectionConfig} />

0 commit comments

Comments
 (0)