Skip to content

fix(FileUpload): Downgrade react-dropzone back to 9.0.0 to avoid a breaking type change, fix behavior regressions#6610

Merged
tlabaj merged 4 commits intopatternfly:mainfrom
mturley:file-upload-regression-fix
Nov 15, 2021
Merged

fix(FileUpload): Downgrade react-dropzone back to 9.0.0 to avoid a breaking type change, fix behavior regressions#6610
tlabaj merged 4 commits intopatternfly:mainfrom
mturley:file-upload-regression-fix

Conversation

@mturley
Copy link
Collaborator

@mturley mturley commented Nov 15, 2021

Closes #6609

In order to keep the changes from #6139 without any breaking TypeScript changes, this reverts react-dropzone to 9.0.0 and makes some tweaks so the new refs/events still work:

  • The Browse button had broken because fix(FileUpload): Improving events in the FileUpload #6139 sets a ref on the hidden <input> in order to make its onClearClick handler work. This ref overrode the internal ref set by react-dropzone and used for the manual browse functionality. This PR sets both refs (using some tricky legacy callback ref stuff) so that both the Browse button and the onClearClick prop can work. The callback refs are not ideal, but can be reverted if we ever end up upgrading to react-dropzone 11+.
    • Note: the getInputProps() function used here does in fact return a ref function that we need for this, even though its TypeScript type says it does not. This is a bug fixed in newer react-dropzone versions, but I work around it here with an as assertion.
  • The basic FileUpload example was broken in fix(FileUpload): Improving events in the FileUpload #6139: the user should not be blocked from typing in the textarea unless they had selected a file. I just needed to add an onTextChange prop to that example.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Nov 15, 2021

@mturley mturley changed the title fix(FileUpload): Downgrade react-dropzone back to 9.0.0 to avoid a breaking type change fix(FileUpload): Downgrade react-dropzone back to 9.0.0 to avoid a breaking type change, fix behavior regressions Nov 15, 2021
@mturley mturley marked this pull request as ready for review November 15, 2021 21:47
Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tlabaj tlabaj merged commit 574bf4f into patternfly:main Nov 15, 2021
@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • eslint-plugin-patternfly-react@4.14.4
  • @patternfly/react-catalog-view-extension@4.26.4
  • @patternfly/react-charts@6.28.4
  • @patternfly/react-code-editor@4.16.4
  • @patternfly/react-console@4.26.4
  • @patternfly/react-core@4.175.4
  • @patternfly/react-docs@5.36.4
  • @patternfly/react-icons@4.26.4
  • @patternfly/react-inline-edit-extension@4.20.4
  • demo-app-ts@4.135.4
  • @patternfly/react-integration@4.137.4
  • @patternfly/react-log-viewer@4.20.4
  • @patternfly/react-styles@4.25.4
  • @patternfly/react-table@4.44.4
  • @patternfly/react-tokens@4.27.4
  • @patternfly/react-topology@4.22.4
  • @patternfly/react-virtualized-extension@4.22.4
  • transformer-cjs-imports@4.13.4

Thanks for your contribution! 🎉

@mturley mturley deleted the file-upload-regression-fix branch November 15, 2021 22:37
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

Successfully merging this pull request may close these issues.

FileUpload: Downgrade react-dropzone back to 9.0.0 to avoid a breaking type change

4 participants