uptick/react-keyed-file-browser

onCreateFolder is not called if onRenameFolder is not provided

Closed this issue · 3 comments

This took quiet some time to debug, but it seems onCreateFolder is not called if onRenameFolder is not defined, we want to enable new folder creation but we don't want to allow renaming of the folder. This is making it impossible.

Trying to find the root cause to avoid it with some sort of monkey patching.

It seems it returns from:

  handleRenameSubmit = (event) => {
    event.preventDefault()
    if (!this.props.browserProps.renameFolder) {
      return
    }

this if in base-folder.js

For now, i had to use local copy of the whole thing to change this one line of if to:

  handleRenameSubmit = (event) => {
    event.preventDefault()
    if (!this.props.browserProps.renameFolder && !this.props.browserProps.createFolder) {
      return
    }

Not even sure if this is correct way to do it, but it works. And we are not using rename so should be fine

The issue is when you create a folder, it immediately wants you to rename this newly created folder.

I think your fix is correct. You could also have used && !this.props.isDraft instead which would enable you to set the name of draft (newly created) folders.
Happy to accept a PR for this fix if you want to raise one.