Skip to content

Commit

Permalink
fix: add class to highlighted element, while it is highlighted
Browse files Browse the repository at this point in the history
  • Loading branch information
josias-r committed Nov 4, 2022
1 parent 7be6bb8 commit e43307f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const CLASS_NEXT_STEP_BTN = "boarding-next-btn";
const CLASS_PREV_STEP_BTN = "boarding-prev-btn";
const CLASS_NAVIGATION_BTNS = "boarding-navigation-btns";
export const CLASS_CUTOUT = "boarding-coutout-svg";
export const CLASS_ACTIVE_HIGHLIGHTED_ELEMENT = "boarding-highlighted-element";

export const CLASS_BTN_DISABLED = "boarding-disabled";
export const CLASS_CLOSE_ONLY_BTN = "boarding-close-only-btn";
Expand Down
8 changes: 8 additions & 0 deletions src/lib/core/highlight-element.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BoardingSharedOptions } from "../boarding-types";
import { CLASS_ACTIVE_HIGHLIGHTED_ELEMENT } from "../common/constants";
import { bringInView } from "../common/utils";
import Popover from "./popover";

Expand Down Expand Up @@ -88,8 +89,12 @@ class HighlightElement {
* i.e. when moving the focus to next element of closing
*/
public onDeselected() {
// hide popover
this.popover?.hide();

// remove active class
this.getElement().classList.remove(CLASS_ACTIVE_HIGHLIGHTED_ELEMENT);

this.options.onDeselected?.(this);
}

Expand All @@ -111,6 +116,9 @@ class HighlightElement {
// the cases where the container has scroll overflow
this.popover?.show(this);

// add active class
this.getElement().classList.add(CLASS_ACTIVE_HIGHLIGHTED_ELEMENT);

this.options.onHighlighted?.(this);
}

Expand Down

0 comments on commit e43307f

Please sign in to comment.