How to receive 'onClose' event of Content Uploader in Content Explorer widget?

I’m using the following snippet, I don’t receive any event in uploaderClose method.

var configData = {

function uploaderClose(e) {
  console.log('close:', e);

var optionsUploader = {
  'onClose' : uploaderClose

var options = {
  'container': '.explorer',
  'contentUploaderProps': optionsUploader

var contentExplorer = new Box.ContentExplorer();, configData.ACCESS_TOKEN, options);

Hi @Niladri

I’m not a javascript/node expert, but I think you’re missing the add listener, something like:

var folder_id = '221723756896';

var options = {
    'container': '.uploader',
    'fileLimit': 100,

    // 'modal': modal,

var contentUploader = new Box.ContentUploader();

console.log('Content Uploader:', contentUploader);

contentUploader.addListener('close', uploaderClose);

function uploaderClose(e) {
    console.log('close:', e);
..., accessToken, options);

I also remember that there is a twist in using this on a modal or not.

Anyway take a look at the full code for the example above in this workshop.


Hi @rbarbosa,

I have gone through the workshop.

The snippet you have provided above is for Content Uploader widget. However, as mentioned in the workshop, we can forward Content Previewer option properties from Content Explorer Widget via ‘contentPreviewProps’ property.

Similarly, As mentioned in the following link, we can forward Content Uploader options properties from Content Explorer via ‘contentUploaderProps’ property.

I was trying to get ‘onClose’ event of Content Uploader from Content Explorer widget. But, I was not able to receive the close event.

@Niladri , this is not forgoten, I’m asking around!!!


Hi @rbarbosa

Thank you for checking on that! I appreciate your effort to follow up.

Hi @Niladri!

I think you’ve found a bug in our code! The ContentExplorer element does indeed pass a contentUploaderProps object to ContentUploader but specifically the onClose prop is being overwritten by ContentExplorer’s own handler for ContentUploader.

Here is where contentUploaderProps and onClose are passed to UploadDialog:

Notice the separate contentUploaderProps and onClose props.

Then contentUploaderProps is being spread to ContentUploader but because the separate onClose prop comes after, it is overriding any onClose that was added to contentUploaderProps:

Hi @tjuanitas

Thanks for the explanation. I hope this will be fixed soon.

Just a quick clarification: The token generator function passed via “contentPreviewProps” will be overridden, thereby preventing us from passing a custom token generation function to the Content Preview widget from Content Explorer widget.

box-ui-elements/src/elements/content-explorer/PreviewDialog.js at 217a39314c43f9b093c4ca55a45772a6f42a9416 · box/box-ui-elements · GitHub

Yeah, that looks like the same issue. out of curiosity, are you using separate token generators for ContentExplorer and ContentPreview?

Hi @tjuanitas,

I’m exploring a range of widget options to try and resolve the preview issue mentioned in the thread below.

Preview error on Content Explorer Widget - Box Platform / UI Elements - Box Developer Community