Skip to content

Commit ebbc4c8

Browse files
anderssonjohanadrianschmidt
authored andcommitted
fix(icon-button): remove sticky focus style when button is clicked
1 parent 759da8b commit ebbc4c8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/components/icon-button/icon-button.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import { IconSize } from '@limetech/lime-elements';
1313
styleUrl: 'icon-button.scss',
1414
})
1515
export class IconButton {
16+
public constructor() {
17+
this.removeFocusedStyleOnClick = this.removeFocusedStyleOnClick.bind(
18+
this
19+
);
20+
}
21+
1622
/**
1723
* The icon to display.
1824
*/
@@ -56,6 +62,13 @@ export class IconButton {
5662
}
5763
}
5864

65+
private removeFocusedStyleOnClick() {
66+
const mdcButton = this.host.shadowRoot.querySelector(
67+
'.mdc-icon-button'
68+
);
69+
mdcButton.classList.remove('mdc-ripple-upgraded--background-focused');
70+
}
71+
5972
public connectedCallback() {
6073
this.initialize();
6174
}
@@ -72,10 +85,12 @@ export class IconButton {
7285

7386
this.mdcIconButtonRipple = new MDCRipple(element);
7487
this.mdcIconButtonRipple.unbounded = true;
88+
this.host.addEventListener('click', this.removeFocusedStyleOnClick);
7589
}
7690

7791
public disconnectedCallback() {
7892
this.mdcIconButtonRipple?.destroy();
93+
this.host.removeEventListener('click', this.removeFocusedStyleOnClick);
7994
}
8095

8196
public render() {

0 commit comments

Comments
 (0)