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

[@wordpress/components] [TypeScript] Unnecessary Requirement of Pointer Events on SVG Components #61322

Open
rafaucau opened this issue May 2, 2024 · 2 comments
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@rafaucau
Copy link

rafaucau commented May 2, 2024

Description

When using SVG-based components such as the Spinner from @wordpress/components, TypeScript errors are generated unless pointer event handlers like onPointerEnterCapture and onPointerLeaveCapture are provided. These properties should not be required for components like <Spinner/>, but the current TypeScript types make them mandatory, leading to an unnecessary complication for developers.

The problem most likely lies in these types: https://github.com/WordPress/gutenberg/blob/ed678300cf67d234b57291b4f5e04505a5d72ec7/packages/components/src/context/wordpress-component.ts

Step-by-step reproduction instructions

  1. Import the Spinner component from @wordpress/components.
  2. Use the Spinner component in a React component like so: <Spinner />.
  3. Observe TypeScript error requiring onPointerEnterCapture and onPointerLeaveCapture which should not be mandatory.

Screenshots, screen recording, code snippet

image

Environment info

  • @wordpress/compoennts: 27.4.0
  • TypeScript: 5.4.5

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@rafaucau rafaucau added the [Type] Bug An existing feature does not function as intended label May 2, 2024
@rafaucau rafaucau changed the title [@wordpress/components] Unnecessary Requirement of Pointer Events on SVG Components [@wordpress/components] [TypeScript] Unnecessary Requirement of Pointer Events on SVG Components May 2, 2024
@skorasaurus skorasaurus added the [Package] Components /packages/components label May 3, 2024
@mirka
Copy link
Member

mirka commented May 7, 2024

What version of @types/react/@types/react-dom are you using in your project? Looks related to DefinitelyTyped/DefinitelyTyped#69006 and #60796.

@rafaucau rafaucau closed this as completed May 7, 2024
@rafaucau rafaucau reopened this May 7, 2024
@rafaucau
Copy link
Author

rafaucau commented May 7, 2024

I have now manually installed the latest version of React types, but it has not helped.

"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",

Up until now I had installed the type versions provided by the @wordpress/* packages.

@gziolo gziolo added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants