Skip to content

Commit

Permalink
fix PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
leagrdv committed Dec 20, 2024
1 parent 0a50c01 commit aab2fa6
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ export class PostLanguageOption {
render() {
const lang = this.code.toLowerCase();

const emitOnKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Enter' || e.key === ' ') {
this.emitChange();
}
};

return (
<Host data-version={version} role={this.variant ? `${this.variant}item` : null}>
{this.url ? (
Expand All @@ -133,11 +139,7 @@ export class PostLanguageOption {
hrefLang={lang}
lang={lang}
onClick={() => this.emitChange()}
onKeyDown={e => {
if (e.key === 'Enter' || e.key === ' ') {
this.emitChange();
}
}}
onKeyDown={emitOnKeyDown}
>
<slot />
</a>
Expand All @@ -147,11 +149,7 @@ export class PostLanguageOption {
aria-label={this.name}
lang={lang}
onClick={() => this.emitChange()}
onKeyDown={e => {
if (e.key === 'Enter' || e.key === ' ') {
this.emitChange();
}
}}
onKeyDown={emitOnKeyDown}
>
<slot />
</button>
Expand Down

0 comments on commit aab2fa6

Please sign in to comment.