Skip to content

Commit db6fd8e

Browse files
authored
Merge pull request #18 from mohsinulhaq/add-trigger-ref
Expose trigger reference
2 parents 0e79959 + d26ba4b commit db6fd8e

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

.size-snapshot.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"dist/index.js": {
3-
"bundled": 7445,
4-
"minified": 7445,
5-
"gzipped": 2208
3+
"bundled": 7471,
4+
"minified": 7471,
5+
"gzipped": 2219
66
},
77
"lib/cjs/index.js": {
8-
"bundled": 14012,
9-
"minified": 7765,
10-
"gzipped": 2141
8+
"bundled": 14096,
9+
"minified": 7791,
10+
"gzipped": 2148
1111
},
1212
"lib/esm/index.js": {
13-
"bundled": 13960,
14-
"minified": 7732,
15-
"gzipped": 2138,
13+
"bundled": 14044,
14+
"minified": 7758,
15+
"gzipped": 2144,
1616
"treeshaked": {
1717
"rollup": {
18-
"code": 7171,
18+
"code": 7197,
1919
"import_statements": 331
2020
},
2121
"webpack": {
22-
"code": 8405
22+
"code": 8431
2323
}
2424
}
2525
}

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ Each placement can have a variation from this list:
229229
230230
The event that triggers the tooltip. One of `click`, `hover`, `right-click`, `none`.
231231

232+
### getTriggerRef
233+
234+
> `function(HTMLElement) => void`
235+
236+
Function that can be used to obtain a trigger element reference.
237+
232238
### closeOnOutOfBoundaries
233239

234240
> `boolean` | defaults to `true`

src/TooltipTrigger.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export default class TooltipTrigger extends Component {
6161
* the event that triggers the tooltip
6262
*/
6363
trigger: T.oneOf(['click', 'hover', 'right-click', 'none']),
64+
/**
65+
* function that can be used to obtain a trigger element reference
66+
*/
67+
getTriggerRef: T.func,
6468
/**
6569
* whether to close the tooltip when it's trigger is out of the boundary
6670
*/
@@ -211,6 +215,7 @@ export default class TooltipTrigger extends Component {
211215
tooltip,
212216
placement,
213217
trigger,
218+
getTriggerRef,
214219
modifiers,
215220
closeOnOutOfBoundaries,
216221
usePortal,
@@ -273,7 +278,7 @@ export default class TooltipTrigger extends Component {
273278

274279
return (
275280
<Manager>
276-
<Reference>
281+
<Reference innerRef={getTriggerRef}>
277282
{({ ref }) =>
278283
children({ getTriggerProps: this.getTriggerProps, triggerRef: ref })
279284
}

0 commit comments

Comments
 (0)