Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button text and close prop to MediaUpload #15969

Open
afercia opened this issue Jun 3, 2019 · 2 comments
Open

Add button text and close prop to MediaUpload #15969

afercia opened this issue Jun 3, 2019 · 2 comments
Labels
[Feature] Media Anything that impacts the experience of managing media [Type] Enhancement A suggestion for improvement.

Comments

@afercia
Copy link
Contributor

afercia commented Jun 3, 2019

Describe the bug
In WordPress core, it's possible to invoke a Media modal with wp.media() and pass a couple properties to the modal "Select" button, ie: the button in the bottom right:

  • text: a custom text for the button
  • close: whether the modal should close when clicking the button

Screenshot 2019-06-03 at 16 50 23

In the Gutenberg MediaUpload it is possible to pass only the Modal title, see:

class MediaUpload extends Component {
constructor( {
allowedTypes,
gallery = false,
modalClass,
multiple = false,
title = __( 'Select or Upload Media' ),
} ) {
super( ...arguments );
this.openModal = this.openModal.bind( this );
this.onOpen = this.onOpen.bind( this );
this.onSelect = this.onSelect.bind( this );
this.onUpdate = this.onUpdate.bind( this );
this.onClose = this.onClose.bind( this );
if ( gallery ) {
this.buildAndSetGalleryFrame();
} else {
const frameConfig = {
title,
button: {
text: __( 'Select' ),
},
multiple,
};
if ( !! allowedTypes ) {
frameConfig.library = { type: allowedTypes };
}
this.frame = wp.media( frameConfig );

1
passing a button text prop seems pretty simple to me and would allow parity with the current usage, when plugins or other core workflows need a better button text.

2
in core, the close prop is set to false when it is necessary to not close the modal and switch to another state/view, for example when the following step is the image cropping (see legacy custom header, custom background pages, and in the Customizer).

I'm not sure if in Gutenberg there is already a way to not close the modal (couldn't find it). If there's none, I'd tend to think it is necessary to implement a similar feature to allow for custom workflows.

Note: MediaUpload has just been extracted to its own package in #15521 /Cc @jorgefilipecosta

@afercia afercia added [Type] Enhancement A suggestion for improvement. [Feature] Media Anything that impacts the experience of managing media labels Jun 3, 2019
@paaljoachim
Copy link
Contributor

paaljoachim commented Jan 12, 2021

Is this issue still relevant?

@joedolson
Joe I am pinging you to older issues that Andrea created (as you probably have noticed).

@joedolson
Copy link
Contributor

Looks to me like nothing has changed here; the issue is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Media Anything that impacts the experience of managing media [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants