diff --git a/lib/core/src/lib/form/components/widgets/button/button.widget.spec.ts b/lib/core/src/lib/form/components/widgets/button/button.widget.spec.ts index 971bd1ce35..444dcf2c4a 100644 --- a/lib/core/src/lib/form/components/widgets/button/button.widget.spec.ts +++ b/lib/core/src/lib/form/components/widgets/button/button.widget.spec.ts @@ -65,6 +65,24 @@ describe('ButtonWidgetComponent', () => { expect(await button.isDisabled()).toBe(true); }); + it('should disable button when the field reference remains the same but the readOnly property changes', async () => { + const sameFieldRef = { ...mockField, readOnly: false }; + + fixture.componentRef.setInput('field', sameFieldRef); + + const button = await getButton(); + const disabledBeforeChange = await button.isDisabled(); + + sameFieldRef.readOnly = true; + + fixture.componentRef.setInput('field', sameFieldRef); + + const disabledAfterChange = await button.isDisabled(); + + expect(disabledBeforeChange).toBe(false); + expect(disabledAfterChange).toBe(true); + }); + it('should attach className to the widget host element', () => { fixture.detectChanges(); diff --git a/lib/core/src/lib/form/components/widgets/button/button.widget.ts b/lib/core/src/lib/form/components/widgets/button/button.widget.ts index 2423cc73c1..4add67d219 100644 --- a/lib/core/src/lib/form/components/widgets/button/button.widget.ts +++ b/lib/core/src/lib/form/components/widgets/button/button.widget.ts @@ -17,7 +17,7 @@ /* eslint-disable @angular-eslint/component-selector */ -import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core'; +import { Component, ViewEncapsulation } from '@angular/core'; import { WidgetComponent } from '../widget.component'; import { FormService } from '../../../services/form.service'; import { TranslatePipe } from '@ngx-translate/core'; @@ -32,7 +32,6 @@ import { MatTooltipModule } from '@angular/material/tooltip'; '[class]': 'hostClasses' }, encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, imports: [TranslatePipe, MatButtonModule, MatTooltipModule] }) export class ButtonWidgetComponent extends WidgetComponent {