-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tooltip - support custom mountNode (#22134)
* Add mountNode prop to tooltip * update rooltip api * change file * fix test in story * update example to use setRef * remove default value of mountNode * Update packages/react-tooltip/src/stories/TooltipCustomMount.stories.tsx Co-authored-by: Makoto Morimoto <[email protected]> * Update change/@fluentui-react-tooltip-79df9179-1dd1-4817-9d7b-623d2a2fe436.json Co-authored-by: Oleksandr Fediashov <[email protected]> * Update packages/react-tooltip/src/stories/TooltipCustomMount.stories.tsx Co-authored-by: Oleksandr Fediashov <[email protected]> Co-authored-by: Makoto Morimoto <[email protected]> Co-authored-by: Oleksandr Fediashov <[email protected]>
- Loading branch information
1 parent
dc052f7
commit f10cc04
Showing
7 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-tooltip-79df9179-1dd1-4817-9d7b-623d2a2fe436.json
This file contains 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,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Add mountNode prop", | ||
"packageName": "@fluentui/react-tooltip", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains 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 contains 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 contains 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 contains 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 contains 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
27 changes: 27 additions & 0 deletions
27
packages/react-tooltip/src/stories/TooltipCustomMount.stories.tsx
This file contains 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,27 @@ | ||
import * as React from 'react'; | ||
|
||
import { Tooltip, TooltipProps } from '../Tooltip'; | ||
import { Button } from '@fluentui/react-button'; | ||
import { SlideTextRegular } from '@fluentui/react-icons'; | ||
|
||
export const CustomMount = (props: Partial<TooltipProps>) => { | ||
const [ref, setRef] = React.useState<HTMLElement | null>(); | ||
|
||
return ( | ||
<> | ||
<Tooltip mountNode={ref} content="Example tooltip" relationship="label" {...props}> | ||
<Button icon={<SlideTextRegular />} size="large" /> | ||
</Tooltip> | ||
<div ref={setRef} /> | ||
</> | ||
); | ||
}; | ||
|
||
CustomMount.parameters = { | ||
docs: { | ||
description: { | ||
story: `Tooltips are rendered in a React Portal. By default that Portal is the outermost div. | ||
A custom \`mountNode\` can be provided in the case that the tooltip needs to be rendered elsewhere.`, | ||
}, | ||
}, | ||
}; |