Skip to content

Commit

Permalink
feat(Tooltip): add innerRef (#1090)
Browse files Browse the repository at this point in the history
Adding a innerRef prop to the `div` wrapping the `Tooltip` so it can accesed _from the outside_

#1089
  • Loading branch information
juanmaguitar authored and TheSharpieOne committed Jun 25, 2018
1 parent 015d16d commit 214da8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/lib/Components/TooltipsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ export default class TooltipsPage extends React.Component {
offset: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
])
]),
// Custom ref handler that will be assigned to the "ref" of the <div> wrapping the tooltip elements
innerRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.string,
PropTypes.object
]),
}`}
</PrismCode>
</pre>
Expand Down
6 changes: 6 additions & 0 deletions src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const propTypes = {
PropTypes.string,
PropTypes.number
]),
innerRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.string,
PropTypes.object
]),
};

const DEFAULT_DELAYS = {
Expand Down Expand Up @@ -231,6 +236,7 @@ class Tooltip extends React.Component {
>
<div
{...attributes}
ref={this.props.innerRef}
className={classes}
role="tooltip"
aria-hidden={this.props.isOpen}
Expand Down

0 comments on commit 214da8c

Please sign in to comment.