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

Option to set default selection #56

Open
0xi4o opened this issue Mar 18, 2019 · 2 comments
Open

Option to set default selection #56

0xi4o opened this issue Mar 18, 2019 · 2 comments

Comments

@0xi4o
Copy link

0xi4o commented Mar 18, 2019

I love this module! I've managed to set it up by looking at the source code. I noticed that selection is stored in state and set when an item is clicked. I think a defaultSelection option would be nice to have.

@raveenakothapally
Copy link

raveenakothapally commented Apr 3, 2019

@ilangorajagopal, I believe you can maintain the selection / default selection via props:

import FileBrowser, { FileRenderers } from "react-keyed-file-browser";
const { TableFile } = FileRenderers;

    <FileBrowser
          onSelectFile={({ key }) =>
            this.setState({
              selectedFile: key
            })
          }
          fileRenderer={props => (
            <TableFile
              {...props}
              isSelected={this.state.selectedFile === props.fileKey}
            />
          )}
          {...otherProps}
    />

As you might have observed, isSelected can be set to true to your default value when appropriate fileKey is matched initially.

@rchawdry
Copy link

rchawdry commented Jul 7, 2019

Does the above open all of the folders that the given default selection is nested within? I couldn't confirm whether this is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants