Skip to content

Commit

Permalink
iconbutton: Move click handler to button instead of image
Browse files Browse the repository at this point in the history
This moves the clickHandler for iconbutons to the <button> elem instead of the nested <img> so that the entire button area is clickable, instead of just the nested image height/width.
  • Loading branch information
lesleyjanenorton committed Sep 21, 2024
1 parent 2d80597 commit df96c16
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/iconbutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ export class IconLinkButton extends LitElement {
}
render() {
return html`
<button title="${this.alt}" class="ghost-btn ghost-icon-btn">
<button title="${this.alt}"
@click=${() => {
this.onClick();
}}
class="ghost-btn ghost-icon-btn">
<img
aria-hidden="true"
@click=${() => {
this.onClick();
}}
src="../../assets/img/${this.icon}.svg"
/>
</button>
Expand All @@ -57,6 +58,10 @@ export class IconLinkButton extends LitElement {

static styles = css`
${ghostButtonStyles}
img {
pointer-events: none;
}
`;
}
customElements.define("mz-iconlink", IconLinkButton);

0 comments on commit df96c16

Please sign in to comment.