Skip to content

Commit 0e85547

Browse files
Merge branch 'next' into ROU-12460-fix-badge-positioning
2 parents 348a9ab + 5d04106 commit 0e85547

65 files changed

Lines changed: 27 additions & 12 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/src/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,6 +3098,7 @@ export namespace Components {
30983098
* The theme determines the visual appearance of the component.
30993099
*/
31003100
"theme"?: "ios" | "md" | "ionic";
3101+
"updateRadiosTabindex": () => Promise<void>;
31013102
/**
31023103
* the value of the radio group.
31033104
*/

core/src/components/radio-group/radio-group.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ComponentInterface, EventEmitter } from '@stencil/core';
22
import { Build, Component, Element, Event, Host, Listen, Method, Prop, State, Watch, h } from '@stencil/core';
33
import { checkInvalidState } from '@utils/forms';
4-
import { renderHiddenInput } from '@utils/helpers';
4+
import { debounce, renderHiddenInput } from '@utils/helpers';
55
import { hostContext } from '@utils/theme';
66

77
import { getIonTheme } from '../../global/ionic-global';
@@ -110,6 +110,15 @@ export class RadioGroup implements ComponentInterface {
110110
this.valueChanged(this.value);
111111
}
112112

113+
/** @internal - Recompute which radio has tabindex 0. Call when radios are added/removed. */
114+
@Method()
115+
async updateRadiosTabindex() {
116+
this.scheduleTabindexUpdate();
117+
}
118+
119+
/** Ensures that the tabindex update is debounced and only called once. */
120+
private scheduleTabindexUpdate = debounce(() => this.setRadioTabindex(this.value), 0);
121+
113122
private setRadioTabindex = (value: any | undefined) => {
114123
const radios = this.getRadios();
115124

core/src/components/radio/radio.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,15 @@ export class Radio implements ComponentInterface {
151151
if (radioGroup) {
152152
this.updateState();
153153
addEventListener(radioGroup, 'ionValueChange', this.updateState);
154+
radioGroup.updateRadiosTabindex();
154155
}
155156
}
156157

157158
disconnectedCallback() {
158159
const radioGroup = this.radioGroup;
159160
if (radioGroup) {
160161
removeEventListener(radioGroup, 'ionValueChange', this.updateState);
162+
radioGroup.updateRadiosTabindex();
161163
this.radioGroup = null;
162164
}
163165
}
-28 Bytes
-117 Bytes
-53 Bytes

0 commit comments

Comments
 (0)