Repository: DevExpress/devextreme-react
Pull request #619 (2021-10-30 09:54:35)

rollback checking changes
roll back [536](https://github.com/DevExpress/devextreme-react/pull/536)


Patch:
diff --git a/packages/devextreme-react/src/core/options-manager.ts b/packages/devextreme-react/src/core/options-manager.ts
index cf23d6a..26b7a22 100644
--- a/packages/devextreme-react/src/core/options-manager.ts
+++ b/packages/devextreme-react/src/core/options-manager.ts
@@ -62,12 +62,6 @@ class OptionsManager {
   }
 
   public update(config: IConfigNode): void {
-    const changedOptions:Array<[string, any]> = [];
-    const optionChangedHandler = ({ value, fullName }) => {
-      changedOptions.push([fullName, value]);
-    };
-    this.instance.on('optionChanged', optionChangedHandler);
-
     const changes = getChanges(config, this.currentConfig);
 
     if (!changes.options && !changes.templates && !changes.removedOptions.length) {
@@ -98,14 +92,6 @@ class OptionsManager {
     });
 
     this.isUpdating = false;
-    this.instance.off('optionChanged', optionChangedHandler);
-
-    changedOptions.forEach(([name, value]) => {
-      const currentPropValue = config.options[name];
-      if (currentPropValue !== value) {
-        this.setValue(name, currentPropValue);
-      }
-    });
     this.currentConfig = config;
     this.instance.endUpdate();
   }


Test patch:
diff --git a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
index 62db2e7..116fd6e 100644
--- a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
+++ b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
@@ -296,36 +296,6 @@ describe('option control', () => {
     expect(Widget.option.mock.calls[0]).toEqual(['complexOption.a', 123]);
   });
 
-  it('extra option call for check changes', () => {
-    const { rerender } = render(
-      <ControlledComponent everyOption={123} anotherOption="const" />,
-    );
-
-    Widget.option.mockImplementation((name: string) => {
-      if (name === 'everyOption') {
-        Widget.option('anotherOption', 'changed');
-        return undefined;
-      }
-      if (name === undefined) {
-        return {
-          everyOption: 234,
-          abotherOption: 'changed',
-        };
-      }
-      return undefined;
-    });
-
-    rerender(
-      <ControlledComponent everyOption={234} anotherOption="const" />,
-    );
-
-    jest.runAllTimers();
-
-    expect(Widget.option.mock.calls.length).toBe(2);
-    expect(Widget.option.mock.calls[0]).toEqual(['everyOption', 234]);
-    expect(Widget.option.mock.calls[1]).toEqual(['anotherOption', 'changed']);
-  });
-
   it('should not rolls back complex option if shallow equals', () => {
     render(
       <ControlledComponent complexOption={{ a: 123, b: 234 }} />,
@@ -818,6 +788,68 @@ describe('onXXXChange', () => {
       expect(onPropChange).toHaveBeenCalledTimes(1);
     });
 
+    it('is called on component changes controlled option', () => {
+      const onPropChange = jest.fn();
+      const { rerender } = render(
+        <TestComponent
+          text="0"
+          onTextChange={onPropChange}
+        />,
+      );
+      expect(onPropChange).not.toBeCalled();
+
+      const sampleProps = { text: '1' };
+      rerender(
+        <TestComponent
+          {...sampleProps}
+          onTextChange={onPropChange}
+        />,
+      );
+      expect(onPropChange).not.toBeCalled();
+
+      fireOptionChange('text', '2');
+      expect(onPropChange).toHaveBeenCalledTimes(1);
+      expect(onPropChange).toBeCalledWith('2');
+
+      fireOptionChange('text', '3');
+      expect(onPropChange).toHaveBeenCalledTimes(2);
+      expect(onPropChange).toBeCalledWith('3');
+    });
+
+    it('is not called if received value is being modified', () => {
+      const ref = React.createRef() as React.RefObject<TestComponent>;
+      const onPropChange = jest.fn();
+      const defaultProps = {
+        text: '0',
+        onTextChange: onPropChange,
+        ref,
+      };
+
+      const { rerender } = render(
+        <TestComponent
+          {...defaultProps}
+        />,
+      );
+
+      onPropChange.mockImplementation((value) => {
+        rerender(
+          <TestComponent
+            {...defaultProps}
+            text={`X${value}`}
+          />,
+        );
+      });
+
+      fireOptionChange('text', '2');
+
+      expect(onPropChange).toHaveBeenCalledTimes(1);
+
+      expect(ref.current?.props.text).toBe('X2');
+      fireOptionChange('text', 'X22');
+      expect(onPropChange).toHaveBeenCalledTimes(2);
+      expect(ref.current?.props.text).toBe('XX22');
+    });
+
     it('is not called if new value is equal', () => {
       const onPropChange = jest.fn();
       render(
diff --git a/packages/devextreme-react/src/core/__tests__/test-component.ts b/packages/devextreme-react/src/core/__tests__/test-component.ts
index dbf3e70..79c2b3b 100644
--- a/packages/devextreme-react/src/core/__tests__/test-component.ts
+++ b/packages/devextreme-react/src/core/__tests__/test-component.ts
@@ -11,7 +11,6 @@ const Widget = {
   on: (event: string, handler: (e: any) => void): void => {
     eventHandlers[event] = handler;
   },
-  off: jest.fn(),
   dispose: jest.fn(),
 };