Skip to content

Commit

Permalink
fix: dont ignore offset on offset modifier on tooltip.js (#814)
Browse files Browse the repository at this point in the history
fixes #376
  • Loading branch information
luxzeitlos authored and FezVrasta committed Aug 22, 2019
1 parent 9e94c98 commit f1f4874
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/tooltip/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ export default class Tooltip {
},
offset: {
...(this._popperOptions.modifiers && this._popperOptions.modifiers.offset),
offset: options.offset,
offset: options.offset ||
this._popperOptions.modifiers && this._popperOptions.modifiers.offset && this._popperOptions.modifiers.offset.offset ||
options.offset,
},
};

Expand Down
15 changes: 13 additions & 2 deletions packages/tooltip/tests/functional/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,12 @@ describe('[tooltip.js]', () => {
});

spyOn(instance, '_show');

expect(document.querySelector('.tooltip')).toBeNull();

then(() => reference.dispatchEvent(new CustomEvent('mouseenter')), hoverTime);
then(() => reference.dispatchEvent(new CustomEvent('mouseleave')), delay * 2);

then(() => {
expect(instance._show).not.toHaveBeenCalled();
done()
Expand Down Expand Up @@ -592,6 +592,17 @@ describe('[tooltip.js]', () => {
done();
});

it('should proxy a `offset` modifier to the Popper.js instance', done => {
instance = new Tooltip(reference, {
title: 'test',
popperOptions: {
modifiers: { offset: { offset: 10 } },
},
}).show();
expect(instance._popperOptions.modifiers.offset.offset).toBe(10);
done();
});

it('should hide on click outside with `options.closeOnClickOutside`', done => {
instance = new Tooltip(reference, {
title: 'foobar',
Expand Down

0 comments on commit f1f4874

Please sign in to comment.