Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gallery: Update media frame state management (WordPress#2488)
* Gallery: Properly set editing option for the media frame; Improve loading of media frame when editing a gallery; Editing a gallery opens media frame in gallery-edit state This sets the editing option based on the values property of our component. Previously, we were replacing the media frame state right before opening the modal, but after views like the menu were created. This caused a few bugs, like the cancel button moving back to the initial "create gallery" state and some labels being incorrect. This creates a selection from any existing IDs and passes it to the frame before it is created to avoid these issues. Additionally, this updates the method for getting a collection of attachments using `wp.media.query` so we can fetch all of the attachment models in one request, rather than relying on seperate requests for each attachment in the gallery. When opening the `wp.media` modal to modify an existing gallery, the frame should be opened in the `gallery-edit` state, rather than the `gallery` state used when selecting images for a new gallery. * Corrected bug where single media selection was not working as expected; Corrected bug where if gallery was empty all media content was loaded.
- Loading branch information