Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#62696 new defect (bug)

Type for `multiple` attribute in `CollectionAdd` and `GalleryAdd` controllers is incorrect

Reported by: mikachan's profile mikachan Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: docs Cc:

Description

The specified type for multiple in the CollectionAdd and GalleryAdd media controllers seems incorrect. It's documented as a boolean, but the actual functionality allows for either a boolean or 'add' as a string.

The attribute has the following todo note next to it:

@todo 'add' doesn't seem do anything special, and gets used as a boolean.

However, 'add' does change the behaviour slightly, as described in this Gutenberg issue:

multiple = true: makes it possible to select multiple items in the Media library but, by default, clicking on the thumbnail of an item automatically deselect the previously selected item. In order to select multiple items, it is necessary to click with SHIFT or CMD/CTRL

multiple = 'add': makes it possible to select multiple items in the Media library and items keep being added simply clicking on their thumbnails, without any need to use the SHIFT or the CMD/CTRL key. In order to deselect a selected item, one can simply click on its correspondent check mark.

I believe these controllers' docs should be updated to allow this attribute to be a boolean or a string. There are two files where the update is required:

  • src/js/media/controllers/collection-add.js
  • src/js/media/controllers/gallery-add.js

Change History (1)

This ticket was mentioned in PR #8012 on WordPress/wordpress-develop by @yogeshbhutkar.


7 weeks ago
#1

  • Keywords has-patch added

## Description
Updated the JSDoc documentation for the multiple attribute in GalleryAdd and CollectionAdd media controllers to accurately reflect its behavior with different values.

### Context
The multiple attribute accepts both boolean and string values, with different behaviors:

  • multiple=true: Requires SHIFT/CMD/CTRL key to select multiple items
  • multiple='add': Allows selecting multiple items by clicking thumbnails directly

### Technical Changes

  • Updated JSDoc type annotation to {boolean|string} in both controllers
  • Added detailed description of behavior differences between true and 'add' values
  • Removed outdated TODO comment that incorrectly suggested 'add' had no special behavior

### Files Changed

  • src/js/media/controllers/gallery-add.js
  • src/js/media/controllers/collection-add.js

Trac ticket: https://core.trac.wordpress.org/ticket/62696

Note: See TracTickets for help on using tickets.