Skip to content

Commit 31245b7

Browse files
committed
fix(tooltip): simplify event handling and fix tests
1 parent 95c36a3 commit 31245b7

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/components/tooltip/tooltip-event-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TooltipController implements ReactiveController {
3737
}
3838

3939
for (const trigger of hide) {
40-
anchor.addEventListener(trigger, (ev) => this._host[hideOnTrigger](ev));
40+
anchor.addEventListener(trigger, this._host[hideOnTrigger]);
4141
}
4242
}
4343

src/components/tooltip/tooltip.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('Tooltip', () => {
7272
expect(tooltip.hideTriggers).to.equal('pointerleave');
7373
expect(tooltip.showDelay).to.equal(500);
7474
expect(tooltip.hideDelay).to.equal(500);
75-
expect(tooltip.message).to.be.undefined;
75+
expect(tooltip.message).to.equal('');
7676
});
7777

7878
it('should render a default arrow', () => {
@@ -86,6 +86,7 @@ describe('Tooltip', () => {
8686
expect(tooltip).dom.to.equal('<igc-tooltip>It works!</igc-tooltip>');
8787
expect(tooltip).shadowDom.to.equal(
8888
`<igc-popover
89+
aria-hidden="true"
8990
flip
9091
shift
9192
>
@@ -102,6 +103,7 @@ describe('Tooltip', () => {
102103
expect(tooltip).dom.to.equal('<igc-tooltip open>It works!</igc-tooltip>');
103104
expect(tooltip).shadowDom.to.equal(
104105
`<igc-popover
106+
aria-hidden="false"
105107
flip
106108
shift
107109
open
@@ -231,13 +233,14 @@ describe('Tooltip', () => {
231233
});
232234

233235
it('should set the tooltip content as plain text if the `message` property is set', async () => {
234-
expect(tooltip.message).to.be.undefined;
236+
expect(tooltip.message).to.equal('');
235237
expect(tooltip).dom.to.equal(
236238
'<igc-tooltip>It works!</igc-tooltip>',
237239
DIFF_OPTIONS
238240
);
239241
expect(tooltip).shadowDom.to.equal(
240242
`<igc-popover
243+
aria-hidden="true"
241244
flip
242245
shift
243246
>
@@ -259,6 +262,7 @@ describe('Tooltip', () => {
259262
);
260263
expect(tooltip).shadowDom.to.equal(
261264
`<igc-popover
265+
aria-hidden="true"
262266
flip
263267
shift
264268
>

src/components/tooltip/tooltip.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,7 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
353353
this.showWithEvent();
354354
};
355355

356-
protected [hideOnTrigger] = (ev: Event) => {
357-
const related = (ev as PointerEvent).relatedTarget as Node | null;
358-
// If the pointer moved into the tooltip element, don't hide
359-
if (related && (this.contains(related) || this._target?.contains(related)))
360-
return;
361-
356+
protected [hideOnTrigger] = () => {
362357
clearTimeout(this._timeoutId);
363358
this._timeoutId = setTimeout(() => this.hideWithEvent(), 180);
364359
};

0 commit comments

Comments
 (0)