From aab2fa6ae7b5402a71961817437e5c5dcecdb5ab Mon Sep 17 00:00:00 2001 From: leagrdv Date: Fri, 20 Dec 2024 15:20:47 +0100 Subject: [PATCH] fix PR comment --- .../post-language-option.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/components/src/components/post-language-option/post-language-option.tsx b/packages/components/src/components/post-language-option/post-language-option.tsx index 0022850217..3e993a989c 100644 --- a/packages/components/src/components/post-language-option/post-language-option.tsx +++ b/packages/components/src/components/post-language-option/post-language-option.tsx @@ -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 ( {this.url ? ( @@ -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} > @@ -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} >