@@ -65,7 +65,7 @@ function DialogProvider(_ref) {
6565      setShow  =  _useState4 [ 1 ] ; 
6666
6767  var  exitedRef  =  ( 0 ,  _react . useRef ) ( true ) ; 
68-   var  cancelRef  =  ( 0 ,  _react . useRef ) ( ) ;  // unmount 的时候,如果还有  dialog 开着,启动它的正常 cancel 流程  
68+   var  cancelRef  =  ( 0 ,  _react . useRef ) ( ) ;  // when  unmount, if some  dialog is still open, trigger its canceling process  
6969
7070  ( 0 ,  _react . useEffect ) ( function  ( )  { 
7171    return  function  ( )  { 
@@ -176,8 +176,8 @@ function DialogProvider(_ref) {
176176  var  mergedOptions  =  _objectSpread ( { } ,  options ,  { } ,  showOptions ,  { 
177177    show : show , 
178178    onExited : handleExited 
179-   } ) ;  // 当  animation === false 的时候, onExited 不会触发  
180-   // 因此,当  show 变成  false 的时候,认为 exited 完成  
179+   } ) ;  // if  animation === false, the  onExited will not get triggered  
180+   // so, when  show turned into  false, it is considered as exited  
181181
182182
183183  ( 0 ,  _react . useEffect ) ( function  ( )  { 
@@ -235,15 +235,25 @@ function DialogUI(_ref4) {
235235      refKey  =  _ref5$refKey  ===  void  0  ? "ref"  : _ref5$refKey , 
236236      otherInputProps  =  _objectWithoutProperties ( _ref5 ,  [ "defaultValue" ,  "refKey" ] ) ; 
237237
238-   var  _useState5  =  ( 0 ,  _react . useState ) ( defaultValue ) , 
238+   var  _useState5  =  ( 0 ,  _react . useState ) ( "" ) , 
239239      _useState6  =  _slicedToArray ( _useState5 ,  2 ) , 
240240      inputValue  =  _useState6 [ 0 ] , 
241241      setInputValue  =  _useState6 [ 1 ] ; 
242242
243-   var  inputRef  =  ( 0 ,  _react . useRef ) ( ) ; 
243+   var  inputRef  =  ( 0 ,  _react . useRef ) ( ) ;  // only set input value to default value when it shows up 
244+ 
244245  ( 0 ,  _react . useEffect ) ( function  ( )  { 
245-     setInputValue ( defaultValue ) ; 
246-   } ,  [ defaultValue ] ) ; 
246+     if  ( show )  { 
247+       setInputValue ( defaultValue ) ; 
248+     } 
249+   } ,  [ show ,  defaultValue ] ) ;  // if it is closed without animation, clear the input directly 
250+ 
251+   ( 0 ,  _react . useEffect ) ( function  ( )  { 
252+     if  ( ! show  &&  animation  ===  false )  { 
253+       setInputValue ( "" ) ; 
254+     } 
255+   } ,  [ show ,  animation ] ) ;  // set autoFocus properly 
256+ 
247257  ( 0 ,  _react . useEffect ) ( function  ( )  { 
248258    if  ( show  &&  input  &&  autoFocus )  { 
249259      inputRef . current . focus ( ) ; 
@@ -281,11 +291,17 @@ function DialogUI(_ref4) {
281291    setInputValue ( e . target . value ) ; 
282292  } 
283293
294+   function  handleExited ( )  { 
295+     // clear the input value on finish of the animation 
296+     setInputValue ( "" ) ; 
297+     onExited ( ) ; 
298+   } 
299+ 
284300  return  _react [ "default" ] . createElement ( _Modal [ "default" ] ,  { 
285301    show : show , 
286302    onHide : handleHide , 
287303    centered : centered , 
288-     onExited : onExited , 
304+     onExited : handleExited , 
289305    animation : animation , 
290306    scrollable : scrollable , 
291307    size : size 
0 commit comments