Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(tooltip): modernize Tooltip to Material Design 3 #4994
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
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
feat(tooltip): modernize Tooltip to Material Design 3 #4994
Changes from 10 commits
744cef9eeadb876a3310fdd1297d9079c49793d397d52cbccbdcf0e5d9a0ab94da1478c1fe84c29fb3d1a1aeb7f525c09b0ad21eda7e1e312f8af9efb44370c58fc3832b20421b6ba12File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use
isWeb. inlinePlatform.OSchecks so the bundler can tree-shake unused platform code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use
as. use proper types for the refThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer read or forward the child's
onPress— the consumer owns the trigger element and spreads the provided handlers, so a disabled trigger doesn't fire. No more divergence from the plain tooltip.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use
as. use proper types for the refThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does
onTouchEndtrigger for mouse actions on web? we also need to consider keyboard on webThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworked: actions now dismiss via an explicit
dismiss()callback instead ofonTouchEnd, so it works for press/click/keyboard everywhere. Web also wiresonFocus/onBlurnow, so the tooltip opens on keyboard focus too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with an explicit
dismiss()passed to theactionsrender function, so dismissal fires for click and keyboard, not just touch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API/implementation needs to change to avoid
React.cloneElementusage (or reading children directly, as they are not type safe and hurt composition.It is used in existing components, but that's something we're revisiting.
There can be various approaches:
Consider them based on how the final API may look like and what's most ergonomic as well as flexible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with the render-prop approach — most ergonomic and flexible of the options, and the only one that actually removes the
cloneElement/children.propsreading rather than relocating it (aTooltip.Triggerpart would still need to clone its child internally). The trigger handlers and theactions'dismissare handed to the consumer to compose, so it's type-safe and ref-free.I scoped this to
Tooltip.Richand left the plainTooltiponcloneElementsince you mentioned that's being revisited separately — do you want me to revisit it in this PR too, or keep it separate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you're refactoring the component already, then update it here. by "existing components" i mean other components that you're not working on.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.