Skip to content

Commit

Permalink
feat(options): add SPACE key handling for options
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisha0 committed Jun 14, 2022
1 parent 8997279 commit 4c456b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/plugins/header/options/option/option.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {attr, boolAttr, ESLBaseElement} from '@exadel/esl/modules/esl-base-element/core';
import {bind} from '@exadel/esl/modules/esl-utils/decorators/bind';
import {ENTER} from '@exadel/esl/modules/esl-utils/dom/keys';
import {ENTER, SPACE} from '@exadel/esl/modules/esl-utils/dom/keys';

import type {UIPOptions} from '../options';

Expand Down Expand Up @@ -39,14 +39,14 @@ export class UIPOption extends ESLBaseElement {
@bind
protected _onClick() {
this.toggleState();
this.$$fire('uip:optionclick');
this.$$fire('uip:option:changed');
}

@bind
protected _onKeydown(e: KeyboardEvent) {
if (ENTER !== e.key) return;
if (ENTER !== e.key && SPACE !== e.key) return;
this.toggleState();
this.$$fire('uip:optionclick');
this.$$fire('uip:option:changed');
}

public toggleState(force?: boolean) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/header/options/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export class UIPOptions extends UIPPlugin {
}

protected bindEvents() {
this.addEventListener('esl:uip:optionclick', this._onOptionClick);
this.addEventListener('esl:uip:option:changed', this._onOptionClick);
this.root?.addEventListener('uip:configchange', this._onRootConfigChange);
}

protected unbindEvents() {
this.removeEventListener('esl:uip:optionclick', this._onOptionClick);
this.removeEventListener('esl:uip:option:changed', this._onOptionClick);
this.root?.removeEventListener('uip:configchange', this._onRootConfigChange);
}

Expand Down

0 comments on commit 4c456b9

Please sign in to comment.