box-ui-elements icon indicating copy to clipboard operation
box-ui-elements copied to clipboard

Suggestion: The handleChange would be useful as a prop for the contentExplorer

Open Lukortech opened this issue 1 year ago • 1 comments

https://github.com/box/box-ui-elements/blob/3ef104035f92441ba67c396641b3ab859c038bdd/src/elements/content-uploader/UploadInput.js#L10

I am working with Box Api using the scaffolding and building the appliction from different elements. My suggestion would be to add an event that'd allow developers to control the selection of contentUploader via props passed down or at least be able to hook onto an event that's exposed at the top level.

I went through the docs and was really surprised not to see a simple code to work;

this.currentContentExplorer = new Box.ContentExplorer();
this.currentContentExplorer.on('chooseFiles', (files: Entry[]) => {
  if(customValidation(files)) this.attachmentsService.upload(files);
});

OR

this.currentContentExplorer = new Box.ContentExplorer();
this.contentExplorerProps = {
  contentUploaderProps: {
    onSelection: (selectedFiles: Entries[]) => boolean; // tells if the files selected are valid to be displayed in the list
  }
}
this.currentContentExplorer.show(
  this.getCurrentFolderId(),
  this.ssoService.refreshedToken),
  this.contentExplorerProps
);

Lukortech avatar Jan 11 '25 01:01 Lukortech

There's the issue with DroppableContent that it passes down onSelect but it doesn't accept it from any other place and it makes it rather difficult to provide other means to react to user selection. onSelect={handleSelectFiles}

Here we see that there are props taken into account but nothing about injecting any validation. https://github.com/Lukortech/box-ui-elements/blob/master/src/elements/content-uploader/ContentUploader.tsx#L1082

Davis seems to have two PRs open one of which even deleted the unused handleChange

Lukortech avatar Jan 14 '25 16:01 Lukortech