-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[TS migration] Migrate 'Tooltip' component to TypeScript #31544
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
Merged
mountiny
merged 31 commits into
Expensify:main
from
software-mansion-labs:@kosmydel/ts/tooltip
Dec 8, 2023
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
d75347f
migrate Tooltip to TS
kosmydel 6e99530
fixes
kosmydel 9296400
more fixes
kosmydel 8a97ea0
fix refs
kosmydel 15d3837
remove unknown type
kosmydel 0f81bb0
refactor
kosmydel 9248025
Change order of props in Tooltip
kosmydel 3f1ba1f
fix
kosmydel 88f20f3
minor changes
kosmydel 9c65d98
reuse some types
kosmydel 542a6d3
fix
kosmydel 316fc40
Add textRef util
blazejkustra b401d93
use children props
kosmydel ac0d976
address review
kosmydel cc80269
use forwardRef
kosmydel bc65c46
address review
kosmydel 2e46aa9
rename file
kosmydel 99eaf18
cleanup
kosmydel 8b73221
make props optional
kosmydel 46268ac
prettier
kosmydel 802a5a6
Merge branch 'main' into @kosmydel/ts/tooltip
kosmydel e971fa0
Merge branch 'main' into @kosmydel/ts/tooltip
kosmydel cf50055
finalize merge
kosmydel 8eb0c72
prettier
kosmydel ffbc724
Merge branch 'main' into @kosmydel/ts/tooltip
kosmydel 1348cb8
address review
kosmydel 461a428
remove forward ref
kosmydel db258e3
Revert "remove forward ref"
kosmydel 203cd81
fix warning on native
kosmydel d1380a5
Merge branch 'main' into @kosmydel/ts/tooltip
kosmydel 629907f
Merge branch 'main' into @kosmydel/ts/tooltip
kosmydel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import {forwardRef} from 'react'; | ||
| import ChildrenProps from '@src/types/utils/ChildrenProps'; | ||
|
|
||
| // We can't use the common component for the Tooltip as Web implementation uses DOM specific method | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| function Tooltip({children}: ChildrenProps, ref: unknown) { | ||
| return children; | ||
| } | ||
|
|
||
| Tooltip.displayName = 'Tooltip'; | ||
|
|
||
| export default forwardRef(Tooltip); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import {BoundsObserver} from '@react-ng/bounds-observer'; | ||
| import React, {useContext, useMemo, useRef} from 'react'; | ||
| import {PopoverContext} from '@components/PopoverProvider'; | ||
| import BaseTooltip from './BaseTooltip'; | ||
| import {TooltipExtendedProps} from './types'; | ||
|
|
||
| function PopoverAnchorTooltip({shouldRender = true, children, ...props}: TooltipExtendedProps) { | ||
| const {isOpen, popover} = useContext(PopoverContext); | ||
| const tooltipRef = useRef<BoundsObserver>(null); | ||
|
|
||
| const isPopoverRelatedToTooltipOpen = useMemo(() => { | ||
| // eslint-disable-next-line @typescript-eslint/dot-notation | ||
| const tooltipNode = tooltipRef.current?.['_childNode'] ?? null; | ||
| if (isOpen && popover?.anchorRef?.current && tooltipNode && (tooltipNode.contains(popover.anchorRef.current) || tooltipNode === popover.anchorRef.current)) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| }, [isOpen, popover]); | ||
|
|
||
| if (!shouldRender || isPopoverRelatedToTooltipOpen) { | ||
| return children; | ||
| } | ||
|
|
||
| return ( | ||
| <BaseTooltip | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...props} | ||
| ref={tooltipRef} | ||
| > | ||
| {children} | ||
| </BaseTooltip> | ||
| ); | ||
| } | ||
|
|
||
| PopoverAnchorTooltip.displayName = 'PopoverAnchorTooltip'; | ||
|
|
||
| export default PopoverAnchorTooltip; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.