Skip to content

Commit 6029611

Browse files
committed
fixup! feat(cdk-experimental/radio): create radio group and button directives
1 parent a7213fc commit 6029611

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/cdk-experimental/radio/radio.spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async function runAccessibilityChecks(root: HTMLElement): Promise<void> {
7979

8080
describe('CdkRadioGroup', () => {
8181
let fixture: ComponentFixture<RadioGroupExample>;
82-
let textDirection = new EventEmitter<Direction>();
82+
let textDirection = signal('ltr');
8383

8484
let radioGroup: DebugElement;
8585
let radioButtons: DebugElement[];
@@ -111,7 +111,7 @@ describe('CdkRadioGroup', () => {
111111
providers: [
112112
{
113113
provide: Directionality,
114-
useValue: {value: 'ltr', change: textDirection},
114+
useFactory: () => ({valueSignal: textDirection}),
115115
},
116116
],
117117
imports: [BidiModule, component],
@@ -120,6 +120,7 @@ describe('CdkRadioGroup', () => {
120120
const fixture = TestBed.createComponent<T>(component);
121121
fixture.detectChanges();
122122
defineTestVariables(fixture);
123+
textDirection.set('ltr');
123124
return fixture;
124125
}
125126

@@ -171,7 +172,7 @@ describe('CdkRadioGroup', () => {
171172
});
172173
}
173174
if (opts?.textDirection !== undefined) {
174-
textDirection.emit(opts.textDirection);
175+
textDirection.set(opts.textDirection);
175176
}
176177
fixture.detectChanges();
177178
defineTestVariables(fixture); // Ensure env vars are up-to-date with the dom.
@@ -502,16 +503,14 @@ describe('CdkRadioGroup', () => {
502503
});
503504

504505
describe('text direction rtl', () => {
505-
beforeEach(() => setupRadioGroup({textDirection: 'rtl'}));
506+
beforeEach(() => setupRadioGroup({textDirection: 'rtl', orientation: 'horizontal'}));
506507

507508
it('should move focus to the next radio button on ArrowLeft', () => {
508-
setupRadioGroup({orientation: 'horizontal'});
509509
left();
510510
expect(isFocused(1)).toBe(true);
511511
});
512512

513513
it('should move focus to the previous radio button on ArrowRight', () => {
514-
setupRadioGroup({orientation: 'horizontal'});
515514
left();
516515
left();
517516
right();
@@ -522,7 +521,6 @@ describe('CdkRadioGroup', () => {
522521
setupRadioGroup({
523522
skipDisabled: true,
524523
disabledOptions: [1, 2],
525-
orientation: 'horizontal',
526524
});
527525
left();
528526
expect(isFocused(3)).toBe(true);

src/cdk-experimental/radio/radio.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,11 @@ import {_IdGenerator} from '@angular/cdk/a11y';
5656
},
5757
})
5858
export class CdkRadioGroup<V> {
59-
/** The directionality (LTR / RTL) context for the application (or a subtree of it). */
60-
private readonly _directionality = inject(Directionality);
61-
6259
/** The CdkRadioButtons nested inside of the CdkRadioGroup. */
6360
private readonly _cdkRadioButtons = contentChildren(CdkRadioButton, {descendants: true});
6461

6562
/** A signal wrapper for directionality. */
66-
protected textDirection = toSignal(this._directionality.change, {
67-
initialValue: this._directionality.value,
68-
});
63+
protected textDirection = inject(Directionality).valueSignal;
6964

7065
/** The RadioButton UIPatterns of the child CdkRadioButtons. */
7166
protected items = computed(() => this._cdkRadioButtons().map(radio => radio.pattern));

0 commit comments

Comments
 (0)