Skip to content

Commit

Permalink
Revert "Prevent option change event firing when changes occur in comp…
Browse files Browse the repository at this point in the history
…onent (DevExpress#712)"

This reverts commit 1966c4e.
  • Loading branch information
dxvladislavvolkov committed Apr 10, 2018
1 parent f185bfe commit f79d125
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 27 deletions.
4 changes: 0 additions & 4 deletions src/core/events-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ export class NgEventsStrategy {

export class EmitterHelper {
strategy: NgEventsStrategy;
lockedValueChangeEvent = false;

constructor(ngZone: NgZone, public component: DxComponent) {
this.strategy = new NgEventsStrategy(component, ngZone);
}
fireNgEvent(eventName: string, eventArgs: any) {
if (this.lockedValueChangeEvent && eventName === 'valueChange') {
return;
}
let emitter = this.component[eventName];
if (emitter) {
emitter.next(eventArgs && eventArgs[0]);
Expand Down
2 changes: 0 additions & 2 deletions templates/component.tst
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ export class <#= it.className #>Component extends <#= baseClass #> <#? implement
}
<#? it.isEditor #>
writeValue(value: any): void {
this.eventHelper.lockedValueChangeEvent = true;
this.value = value;
this.eventHelper.lockedValueChangeEvent = false;
}
<#? it.widgetName !== "dxRangeSelector" #>
setDisabledState(isDisabled: boolean): void {
Expand Down
21 changes: 0 additions & 21 deletions tests/src/ui/custom-value-accessor-implementation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ describe('DxTextBox value accessor', () => {

expect(instance.option('disabled')).toBe(false);
}));

it('should change the value', async(() => {
let fixture = TestBed.createComponent(TestContainerComponent);
fixture.detectChanges();
Expand All @@ -90,7 +89,6 @@ describe('DxTextBox value accessor', () => {

expect(instance.option('value')).toBe('text');
}));

it('should change touched option', async(() => {
let fixture = TestBed.createComponent(TestContainerComponent);
fixture.detectChanges();
Expand All @@ -104,23 +102,4 @@ describe('DxTextBox value accessor', () => {

expect(fixture.componentInstance.formControl.touched).toBe(true);
}));

it('should not fire valueChanges event when patchValue method is used with emitEvent=false (T614207)', () => {
let fixture = TestBed.createComponent(TestContainerComponent);
fixture.detectChanges();

let component = fixture.componentInstance,
form = component.form,
testSpy = jasmine.createSpy('testSpy');

form.valueChanges.subscribe(testSpy);

form.controls['formControl'].patchValue('text', { emitEvent: false });
fixture.detectChanges();
expect(testSpy).toHaveBeenCalledTimes(0);

form.controls['formControl'].patchValue('text2');
fixture.detectChanges();
expect(testSpy).toHaveBeenCalledTimes(1);
});
});

0 comments on commit f79d125

Please sign in to comment.