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 support for onFocus and onBlur props #143

Open
billfienberg opened this issue Jul 9, 2020 · 3 comments
Open

Add support for onFocus and onBlur props #143

billfienberg opened this issue Jul 9, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@billfienberg
Copy link

billfienberg commented Jul 9, 2020

Is your feature request related to a problem? Please describe.

I'm always frustrated when I can't add imperatively add a focus state to the wrapper when the input is focused.

Describe the solution you'd like
Update the render method to accept onFocus and onBlur props, and pass those props to the input element.

For example:

render() {
    const {
      id,
      name,
      className,
      allowMultiple,
      required,
      captureMethod,
      acceptedFileTypes
      onFocus, 
      onBlur, 
    } = this.props;
    return createElement(
      'div',
      { className: 'filepond--wrapper' },
      createElement('input', {
        type: 'file',
        name,
        id,
        accept: acceptedFileTypes,
        multiple: allowMultiple,
        required: required,
        className: className,
        capture: captureMethod,
        onFocus: onFocus,
        onBlur: onBlur,
        ref: element => (this._element = element)
      })
    );
  }

Describe alternatives you've considered

  • Refs
  • Adding event listeners in the onInit handler

Additional context
Issues search results for focus: https://github.com/pqina/react-filepond/issues?q=is%3Aissue+focus
Issues search results for blur: https://github.com/pqina/react-filepond/issues?q=is%3Aissue+blur

@rikschennink
Copy link
Collaborator

Thanks for the detailed issue report. This would be useful I think, I'm on a short trip, can probably pick this up later this month, PR is welcome as well.

@rikschennink rikschennink added the enhancement New feature or request label Jul 23, 2020
@rikschennink
Copy link
Collaborator

I experimented with this a bit. The above solution wouldn't work.

We'd need to add custom onblur and onfocus callbacks to the FilePond core (you can enter the FilePond drop area and navigate over multiple files before leaving). Then we can expose the above onFocus and onBlur handlers on the react adapter and link them to the custom core callbacks.

@sitch
Copy link

sitch commented May 2, 2023

bump

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

No branches or pull requests

3 participants