Skip to content

Commit

Permalink
fix link clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Dec 2, 2024
1 parent e77ee23 commit 49f8ee7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client/src/about/custom-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TeamMember extends LitElement {
}
}

_focusout({ relatedTarget }) {
_focusout() {
const hx = this.querySelector("h4, h5");
const panel = hx?.closest(".tabpanel");
window.history.pushState({}, "", `#${panel?.id || ""}`);
Expand All @@ -54,19 +54,27 @@ export class TeamMember extends LitElement {
return this;
}

_mousedown({ target, preventDefault }) {
if (target?.tagName === "A") {
preventDefault?.();
}
}

connectedCallback() {
super.connectedCallback();
this.tabIndex = 0;
this._setID();
if (window.location.hash === `#${this.id}`) {
setTimeout(() => this.focus(), 100);
}
this.addEventListener("mousedown", this._mousedown);
this.addEventListener("focusin", this._focusin);
this.addEventListener("focusout", this._focusout);
}

disconnectedCallback() {
super.disconnectedCallback();
this.removeEventListener("mousedown", this._mousedown);
this.removeEventListener("focusin", this._focusin);
this.removeEventListener("focusout", this._focusout);
}
Expand Down

0 comments on commit 49f8ee7

Please sign in to comment.