Skip to content

Commit

Permalink
fix: could not save selection from upload has many drawer (#9325)
Browse files Browse the repository at this point in the history
### 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.
  • Loading branch information
JarrodMFlesch authored Nov 19, 2024
1 parent bb4f69f commit f42b1e1
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/ui/src/views/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Pagination } from '../../elements/Pagination/index.js'
import { PerPage } from '../../elements/PerPage/index.js'
import { PublishMany } from '../../elements/PublishMany/index.js'
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'
import { SelectMany } from '../../elements/SelectMany/index.js'
import { useStepNav } from '../../elements/StepNav/index.js'
import { RelationshipProvider } from '../../elements/Table/RelationshipProvider/index.js'
import { TableColumnsProvider } from '../../elements/TableColumns/index.js'
Expand All @@ -36,8 +37,8 @@ import { useListQuery } from '../../providers/ListQuery/index.js'
import { SelectionProvider } from '../../providers/Selection/index.js'
import { useTranslation } from '../../providers/Translation/index.js'
import { useWindowInfo } from '../../providers/WindowInfo/index.js'
import './index.scss'
import { ListHeader } from './ListHeader/index.js'
import './index.scss'

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

const [Table, setTable] = useState(InitialTable)

const { createNewDrawerSlug, drawerSlug: listDrawerSlug } = useListDrawerContext()
const { createNewDrawerSlug, drawerSlug: listDrawerSlug, onBulkSelect } = useListDrawerContext()

useEffect(() => {
if (InitialTable) {
Expand Down Expand Up @@ -197,7 +198,13 @@ export const DefaultListView: React.FC<ListViewClientProps> = (props) => {
t={t}
/>
<ListControls
beforeActions={beforeActions}
beforeActions={
enableRowSelections && typeof onBulkSelect === 'function'
? beforeActions
? [...beforeActions, <SelectMany key="select-many" onClick={onBulkSelect} />]
: [<SelectMany key="select-many" onClick={onBulkSelect} />]
: beforeActions
}
collectionConfig={collectionConfig}
collectionSlug={collectionSlug}
disableBulkDelete={disableBulkDelete}
Expand Down Expand Up @@ -265,7 +272,14 @@ export const DefaultListView: React.FC<ListViewClientProps> = (props) => {
label={getTranslation(collectionConfig.labels.plural, i18n)}
/>
<div className={`${baseClass}__list-selection-actions`}>
{beforeActions && beforeActions}
{enableRowSelections && typeof onBulkSelect === 'function'
? beforeActions
? [
...beforeActions,
<SelectMany key="select-many" onClick={onBulkSelect} />,
]
: [<SelectMany key="select-many" onClick={onBulkSelect} />]
: beforeActions}
{!disableBulkEdit && (
<Fragment>
<EditMany collection={collectionConfig} />
Expand Down

0 comments on commit f42b1e1

Please sign in to comment.