Skip to content

Commit 0ed1584

Browse files
committed
accessibility(Materialbox) implement remove event listener for keyboard interaction
1 parent e794f02 commit 0ed1584

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/materialbox.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,26 @@ export class Materialbox extends Component<MaterialboxOptions> {
135135

136136
private _removeEventHandlers() {
137137
this.el.removeEventListener('click', this._handleMaterialboxClick);
138+
this.el.removeEventListener('keypress', this._handleMaterialboxKeypress);
138139
}
139140

140141
private _handleMaterialboxClick = () => {
141142
this._handleMaterialboxToggle();
142143
};
144+
143145
private _handleMaterialboxKeypress = (e: KeyboardEvent) => {
144146
if (Utils.keys.ENTER.includes(e.key)) {
145147
this._handleMaterialboxToggle();
146148
}
147149
};
150+
148151
private _handleMaterialboxToggle = () => {
149152
// If already modal, return to original
150153
if (this.doneAnimating === false || (this.overlayActive && this.doneAnimating))
151154
this.close();
152155
else
153156
this.open();
154-
}
157+
};
155158

156159
private _handleWindowScroll = () => {
157160
if (this.overlayActive) this.close();

0 commit comments

Comments
 (0)