Преглед изворни кода

fix: toast support motion false

代强 пре 3 година
родитељ
комит
19a43337ab

+ 2 - 0
packages/semi-ui/_cssAnimation/index.tsx

@@ -57,6 +57,7 @@ class CSSAnimation extends React.Component<AnimationProps, AnimationState> {
         this.props.onAnimationStart?.();
         if (!this.props.motion){
             this.props.onAnimationEnd?.(false);
+            this.setState({ isAnimating: false });
         }
     }
 
@@ -74,6 +75,7 @@ class CSSAnimation extends React.Component<AnimationProps, AnimationState> {
                 this.props.onAnimationStart?.();
                 if (!this.props.motion) {
                     this.props.onAnimationEnd?.(this.state.isAnimating);
+                    this.setState({ isAnimating: false });
                 }
             });
         }

+ 1 - 0
packages/semi-ui/toast/__test__/toast-command-call.test.js

@@ -22,6 +22,7 @@ describe('Toast - 2', () => {
         let opts = {
             content: 'close by manual',
             duration: 0,
+            motion:false
         };
         let id = Toast.info(opts);
         let toast = document.getElementsByClassName(`${BASE_CLASS_PREFIX}-toast-info`);

+ 4 - 3
packages/semi-ui/toast/__test__/toast.test.js

@@ -34,6 +34,7 @@ describe('Toast', () => {
         let opts = {
             duration: 1,
             content: 'dur1',
+            motion:false,
         };
         Toast.info(opts);
         let toast = document.querySelector(`.${BASE_CLASS_PREFIX}-toast-info`);
@@ -47,14 +48,14 @@ describe('Toast', () => {
     });
     it('update content by id', done => {
         const id = 'toastid'
-        Toast.info({ content: 'bytedance', id });
+        Toast.info({ content: 'bytedance', id, motion: false });
         let toast = document.querySelector(`.${BASE_CLASS_PREFIX}-toast-info`);
         expect(toast.textContent).toEqual('bytedance');
         setTimeout(() => {
-            Toast.info({ content: 'dancebyte', id });
+            Toast.info({ content: 'dancebyte', id, motion: false });
             expect(toast.textContent).toEqual('dancebyte');
             setTimeout(() => {
-                Toast.error({ content: 'error', id });
+                Toast.error({ content: 'error', id, motion: false});
                 expect(toast.textContent).toEqual('error');
                 expect(toast?.className).toEqual(`${BASE_CLASS_PREFIX}-toast ${BASE_CLASS_PREFIX}-toast-error`)
                 done()