Skip to content

Commit 362270f

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

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, DebugElement, EventEmitter, signal, Type, WritableSignal} from '@angular/core';
1+
import {Component, DebugElement, signal, Type, WritableSignal} from '@angular/core';
22
import {CdkRadioButton, CdkRadioGroup} from './radio';
33
import {ComponentFixture, TestBed} from '@angular/core/testing';
44
import {By} from '@angular/platform-browser';
@@ -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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
} from '@angular/core';
2222
import {RadioButtonPattern, RadioGroupPattern} from '../ui-patterns';
2323
import {Directionality} from '@angular/cdk/bidi';
24-
import {toSignal} from '@angular/core/rxjs-interop';
2524
import {_IdGenerator} from '@angular/cdk/a11y';
2625

2726
/**
@@ -56,16 +55,11 @@ import {_IdGenerator} from '@angular/cdk/a11y';
5655
},
5756
})
5857
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-
6258
/** The CdkRadioButtons nested inside of the CdkRadioGroup. */
6359
private readonly _cdkRadioButtons = contentChildren(CdkRadioButton, {descendants: true});
6460

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

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

0 commit comments

Comments
 (0)