Repository: DevExpress/devextreme-react
Pull request #620 (2021-10-30 10:04:22)

rollback checking changes 


Patch:
diff --git a/packages/devextreme-react/src/core/options-manager.ts b/packages/devextreme-react/src/core/options-manager.ts
index edefab7..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,15 +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 fa76f7b..8f22464 100644
--- a/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
+++ b/packages/devextreme-react/src/core/__tests__/props-updating.test.tsx
@@ -765,6 +765,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(),
 };