Product Editor: Fix crash when uploading files from variations list Quick Update menu (#45748)

* Handle when downloads menu is passed an empty selection

* Changelog
This commit is contained in:
Matt Sherman 2024-03-20 14:24:15 -04:00 committed by GitHub
parent 87bfa48638
commit 4272a782a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Product Editor: "Upload files" quick update menu for variations does not crash variations list.

View File

@ -33,9 +33,12 @@ export function DownloadsMenuItem( {
}: VariationActionsMenuItemProps ) {
const ids = selection.map( ( { id } ) => id );
const downloadsIds: number[] = selection[ 0 ].downloads.map(
( { id }: ProductDownload ) => Number.parseInt( id, 10 )
);
const downloadsIds: number[] =
selection?.length > 0
? selection[ 0 ].downloads.map( ( { id }: ProductDownload ) =>
Number.parseInt( id, 10 )
)
: [];
const [ uploadFilesModalOpen, setUploadFilesModalOpen ] = useState( false );