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

[core] Fix render prop types #1213

Merged
merged 5 commits into from
Dec 23, 2024
Merged

[core] Fix render prop types #1213

merged 5 commits into from
Dec 23, 2024

Conversation

atomiks
Copy link
Contributor

@atomiks atomiks commented Dec 23, 2024

Continues #1209

Switches to GenericHTMLProps for the render props type. This includes the ref which was previously missing. Using 'div' for Tooltip uses the GenericHTMLProps regardless.

@atomiks atomiks added core Infrastructure work going on behind the scenes component: tooltip This is the name of the generic UI component, not the React module! labels Dec 23, 2024
@mui-bot
Copy link

mui-bot commented Dec 23, 2024

Netlify deploy preview

https://deploy-preview-1213--base-ui.netlify.app/

Generated by 🚫 dangerJS against 97e168d

@@ -46,14 +46,18 @@ namespace TooltipTrigger {
open: boolean;
}

export interface Props extends BaseUIComponentProps<any, State> {}
export interface Props extends BaseUIComponentProps<'div', State> {}
Copy link
Member

Choose a reason for hiding this comment

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

Do we expect here people to always need to cast if they use different element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The render prop's props parameter is actually loosely typed in order to allow you to compose different tags.

We need to ensure we document when a tag can't be replaced if we aren't polyfilling native behavior (e.g. if it relies in a specific tag's native props in order to work, like <button> being replaced with a <span>, but internally is not using useButton() to keep it accessible).

We could actually remove the first tag type since it serves no purpose in this case

Copy link
Member

Choose a reason for hiding this comment

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

Let's see if this will be enough, if we see more issues around this we can revisit it.

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Can we add types test please? We could add TooltipTrigger.spec.ts file with different use-cases.

@atomiks atomiks merged commit 46dba37 into mui:master Dec 23, 2024
23 checks passed
@atomiks atomiks deleted the fix/render-types branch December 24, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tooltip This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants