Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions src/material/button-toggle/button-toggle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {dispatchMouseEvent} from '@angular/cdk/testing/private';
import {
Component,
DebugElement,
provideCheckNoChangesConfig,
QueryList,
ViewChild,
ViewChildren,
} from '@angular/core';
import {Component, DebugElement, QueryList, ViewChild, ViewChildren} from '@angular/core';
import {ComponentFixture, TestBed, fakeAsync, flush, tick} from '@angular/core/testing';
import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/forms';
import {By} from '@angular/platform-browser';
Expand All @@ -19,21 +12,6 @@ import {
} from './index';

describe('MatButtonToggle with forms', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatButtonToggleModule,
FormsModule,
ReactiveFormsModule,
ButtonToggleGroupWithNgModel,
ButtonToggleGroupWithFormControl,
ButtonToggleGroupWithIndirectDescendantToggles,
ButtonToggleGroupWithFormControlAndDynamicButtons,
],
});
}));

describe('using FormControl', () => {
let fixture: ComponentFixture<ButtonToggleGroupWithFormControl>;
let groupDebugElement: DebugElement;
Expand Down Expand Up @@ -333,27 +311,6 @@ describe('MatButtonToggle with forms', () => {
});

describe('MatButtonToggle without forms', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatButtonToggleModule,
ButtonTogglesInsideButtonToggleGroup,
ButtonTogglesInsideButtonToggleGroupMultiple,
FalsyButtonTogglesInsideButtonToggleGroupMultiple,
ButtonToggleGroupWithInitialValue,
StandaloneButtonToggle,
ButtonToggleWithAriaLabel,
ButtonToggleWithAriaLabelledby,
RepeatedButtonTogglesWithPreselectedValue,
ButtonToggleWithTabindex,
ButtonToggleWithStaticName,
ButtonToggleWithStaticChecked,
ButtonToggleWithStaticAriaAttributes,
],
});
}));

describe('inside of an exclusive selection group', () => {
let fixture: ComponentFixture<ButtonTogglesInsideButtonToggleGroup>;
let groupDebugElement: DebugElement;
Expand Down
14 changes: 6 additions & 8 deletions src/material/button-toggle/button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ import {
OnInit,
Output,
QueryList,
signal,
ViewChild,
ViewEncapsulation,
WritableSignal,
} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {_animationsDisabled, _StructuralStylesLoader, MatPseudoCheckbox, MatRipple} from '../core';
Expand Down Expand Up @@ -450,7 +452,6 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After
}
}
}
this._markButtonsForCheck();
}

/** Obtain the subsequent toggle to which the focus shifts. */
Expand Down Expand Up @@ -613,15 +614,12 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
/** Tabindex of the toggle. */
@Input()
get tabIndex(): number | null {
return this._tabIndex;
return this._tabIndex();
}
set tabIndex(value: number | null) {
if (value !== this._tabIndex) {
this._tabIndex = value;
this._markForCheck();
}
this._tabIndex.set(value);
}
private _tabIndex: number | null;
private _tabIndex: WritableSignal<number | null>;

/** Whether ripples are disabled on the button toggle. */
@Input({transform: booleanAttribute}) disableRipple: boolean;
Expand Down Expand Up @@ -691,7 +689,7 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
{optional: true},
);

this._tabIndex = parseInt(defaultTabIndex) || 0;
this._tabIndex = signal<number | null>(parseInt(defaultTabIndex) || 0);
this.buttonToggleGroup = toggleGroup;
this.appearance =
defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard';
Expand Down
Loading