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

Patch react-autosize-textarea for updated types #61570

Merged
merged 2 commits into from
May 10, 2024

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented May 10, 2024

What?

Patch react-autosize-textarea to fix some type issues. This should be a harmless change.

There are bigger problems with the library that can be addressed, see #61568.

This is a short term fix that should be harmless and fix some build issues.

Extracted from #61486

Why?

Incompatible types can cause this to break because there are type errors between the library and recent React types.

How?

Patch the package to remove references to some keys that no longer exist in the React types.

Testing Instructions

On install you'll see the following (note react-autosize-textarea@7.1.0 ✔):

> gutenberg@18.3.0 postinstall
> patch-package && node ./patches/patch-xcode.js

patch-package 8.0.0
Applying patches...
lighthouse@10.4.0 ✔
react-autosize-textarea@7.1.0 ✔
react-devtools-core@4.28.5 ✔
react-native@0.73.3 ✔

CI is sufficient for testing.

@sirreal sirreal added the [Type] Task Issues or PRs that have been broken down into an individual action to take label May 10, 2024
Copy link
Member Author

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

This removes onPointerEnterCapture" and onPointerLeaveCapture, which were removed from React.

facebook/react#17883

@sirreal sirreal marked this pull request as ready for review May 10, 2024 10:41
Copy link

github-actions bot commented May 10, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@@ -0,0 +1,13 @@
diff --git a/node_modules/react-autosize-textarea/lib/TextareaAutosize.d.ts b/node_modules/react-autosize-textarea/lib/TextareaAutosize.d.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

So by adding a patches file like that, npm automatically overrides the dependency or something? How does that work. TIL

Copy link
Contributor

Choose a reason for hiding this comment

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

Also is there a way to add a comment or something to explain why we need the patch? Git blame might suffice though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yarn has this functionality built in. Gutenberg uses the patch-package package and runs it on postinstall to do the patching:

"postinstall": "patch-package && node ./patches/patch-xcode.js",

I'll add a README to the patches dir, that's a good plan.

@sirreal sirreal requested a review from youknowriad May 10, 2024 14:24
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

The README is very useful. Thank you.

@sirreal sirreal enabled auto-merge (squash) May 10, 2024 14:34
@sirreal sirreal merged commit e84c4a4 into trunk May 10, 2024
63 checks passed
@sirreal sirreal deleted the fix/type-issues-react-autosize-textarea branch May 10, 2024 14:58
@github-actions github-actions bot added this to the Gutenberg 18.4 milestone May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants