Skip to content

Commit

Permalink
fixup! fixup! Feat(web): Tooltip hover
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelklibani committed Feb 12, 2024
1 parent 877f5a5 commit 8a232be
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/web/src/js/Tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Tooltip extends BaseComponent {
trigger?: HTMLElement;
isToggled: boolean;
isHovered: boolean;
activeTrigger: object;
activeTrigger: { [key: string]: boolean };

constructor(element: SpiritElement, config?: SpiritConfig) {
if (typeof FloatingUI === 'undefined') {
Expand Down Expand Up @@ -406,25 +406,27 @@ class Tooltip extends BaseComponent {

EventHandler.on(document, EVENT_CLICK, (event: Event) => this.autoCloseHandler(event));

EventHandler.on(button, EVENT_CLICK, (event) => {
EventHandler.on(button, EVENT_CLICK, () => {
const context = Tooltip.getOrCreateInstance(this.element as HTMLElement);
console.log('click instance', context);
// context.activeTrigger[TRIGGER_CLICK] = true;
context.toggle();
});

this.addMouseEventListeners();
if (enableHover) {
this.addMouseEventListeners();
}
}

addMouseEventListeners() {
const button = this.trigger?.querySelector('button') as HTMLButtonElement;
EventHandler.on(button, EVENT_MOUSEENTER, (event) => {
EventHandler.on(button, EVENT_MOUSEENTER, () => {
const context = Tooltip.getOrCreateInstance(this.element as HTMLElement);
console.log('hover enter', context);
context.activeTrigger[TRIGGER_HOVER] = true;
context.enter();
});
EventHandler.on(button, EVENT_MOUSELEAVE, (event) => {
EventHandler.on(button, EVENT_MOUSELEAVE, () => {
const context = Tooltip.getOrCreateInstance(this.element as HTMLElement);
console.log('hover leave', context, context.activeTrigger);
context.activeTrigger[TRIGGER_HOVER] = false;
Expand Down

0 comments on commit 8a232be

Please sign in to comment.