refactor(radio-group): switch ev.code to ev.key (#27021)

Co-authored-by: Sean Perkins <sean@ionic.io>
This commit is contained in:
Maria Hutt
2023-03-24 12:43:04 -07:00
committed by GitHub
parent 6cecdf4145
commit 1ea0893643

View File

@ -126,13 +126,13 @@ export class RadioGroup implements ComponentInterface {
// If hitting arrow down or arrow right, move to the next radio
// If we're on the last radio, move to the first radio
if (['ArrowDown', 'ArrowRight'].includes(ev.code)) {
if (['ArrowDown', 'ArrowRight'].includes(ev.key)) {
next = index === radios.length - 1 ? radios[0] : radios[index + 1];
}
// If hitting arrow up or arrow left, move to the previous radio
// If we're on the first radio, move to the last radio
if (['ArrowUp', 'ArrowLeft'].includes(ev.code)) {
if (['ArrowUp', 'ArrowLeft'].includes(ev.key)) {
next = index === 0 ? radios[radios.length - 1] : radios[index - 1];
}
@ -146,7 +146,7 @@ export class RadioGroup implements ComponentInterface {
// Update the radio group value when a user presses the
// space bar on top of a selected radio
if (['Space'].includes(ev.code)) {
if ([' '].includes(ev.key)) {
this.value = this.allowEmptySelection && this.value !== undefined ? undefined : current.value;
// Prevent browsers from jumping