dtable-ui-component 5.3.9 → 5.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  border-radius: 3px;
6
6
  z-index: 100;
7
7
  padding: 0.75rem;
8
- line-height: normal;
8
+ line-height: 16px;
9
9
  position: absolute;
10
10
  box-shadow: rgba(0, 0, 0, 0.3) 0px 0px 2px, rgba(0, 0, 0, 0.3) 0px 4px 4px;
11
11
  }
@@ -12,19 +12,22 @@ const ANIMATION_DURATION = 240;
12
12
  class Toast extends _react.default.PureComponent {
13
13
  constructor() {
14
14
  super(...arguments);
15
+ this._isMounted = false;
15
16
  this.state = {
16
- isShown: true,
17
- height: 0
17
+ isShown: true
18
18
  };
19
+ this.containerRef = /*#__PURE__*/_react.default.createRef();
19
20
  this.close = event => {
20
21
  if (event) {
21
22
  event.nativeEvent.stopImmediatePropagation();
22
23
  event.stopPropagation();
23
24
  }
24
25
  this.clearCloseTimer();
25
- this.setState({
26
- isShown: false
27
- });
26
+ if (this._isMounted) {
27
+ this.setState({
28
+ isShown: false
29
+ });
30
+ }
28
31
  };
29
32
  this.startCloseTimer = () => {
30
33
  if (this.props.duration) {
@@ -47,12 +50,12 @@ class Toast extends _react.default.PureComponent {
47
50
  };
48
51
  this.onRef = ref => {
49
52
  if (ref === null) return;
50
- const {
51
- height
52
- } = ref.getBoundingClientRect();
53
- this.setState({
54
- height
55
- });
53
+ setTimeout(() => {
54
+ const {
55
+ height
56
+ } = ref.getBoundingClientRect();
57
+ this.containerRef.current.style.height = height + 'px';
58
+ }, 1);
56
59
  };
57
60
  }
58
61
  componentDidUpdate(prevProps) {
@@ -64,9 +67,11 @@ class Toast extends _react.default.PureComponent {
64
67
  }
65
68
  }
66
69
  componentDidMount() {
70
+ this._isMounted = true;
67
71
  this.startCloseTimer();
68
72
  }
69
73
  componentWillUnmount() {
74
+ this._isMounted = false;
70
75
  this.clearCloseTimer();
71
76
  }
72
77
  render() {
@@ -82,10 +87,9 @@ class Toast extends _react.default.PureComponent {
82
87
  onMouseEnter: this.handleMouseEnter,
83
88
  onMouseLeave: this.handleMouseLeave,
84
89
  style: {
85
- height: this.state.height,
86
- zIndex: this.props.zIndex,
87
- marginBottom: this.state.isShown ? 0 : -this.state.height
88
- }
90
+ zIndex: this.props.zIndex
91
+ },
92
+ ref: this.containerRef
89
93
  }, /*#__PURE__*/_react.default.createElement("div", {
90
94
  ref: this.onRef,
91
95
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "5.3.9",
3
+ "version": "5.3.10",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "3.0.1",