Skip to content

Commit 853b56e

Browse files
bradchristensenTheSharpieOne
authored andcommitted
fix(Tooltip): fix render failure if target ref is null (#1734)
This commit fixes an issue in the `getTarget` function, which was returning `[null]` when the allElements param was true and the ref passed in had a 'current' value of `null`. The downstream effect of this was that tooltips would fail to render. The `getTarget` function now returns an empty array ([]). Fixes #1686
1 parent 87a6bda commit 853b56e

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/__tests__/utils.spec.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ describe('Utils', () => {
189189
it('should return null if the `current` property of the target is null', () => {
190190
const target = { current: null };
191191
expect(Utils.getTarget(target)).toBeNull();
192+
expect(Utils.getTarget(target, true)).toStrictEqual([]);
192193
});
193194
});
194195

‎src/utils.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ export function getTarget(target, allElements) {
305305
if (isArrayOrNodeList(els)) {
306306
return els;
307307
}
308+
if (els === null) {
309+
return [];
310+
}
308311
return [els];
309312
} else {
310313
if (isArrayOrNodeList(els)) {

0 commit comments

Comments
 (0)