|
1 | 1 | import PropTypes from '../_util/vue-types'; |
2 | 2 | import { alignElement, alignPoint } from 'dom-align'; |
3 | 3 | import addEventListener from '../_util/Dom/addEventListener'; |
4 | | -import { isWindow, buffer, isSamePoint } from './util'; |
| 4 | +import { isWindow, buffer, isSamePoint, isSimilarValue, restoreFocus } from './util'; |
5 | 5 | import { cloneElement } from '../_util/vnode.js'; |
6 | 6 | import clonedeep from 'lodash/cloneDeep'; |
7 | 7 | import { getSlot } from '../_util/props-util'; |
@@ -73,7 +73,7 @@ export default { |
73 | 73 | if ( |
74 | 74 | !reAlign && |
75 | 75 | source && |
76 | | - (preRect.width !== sourceRect.width || preRect.height !== sourceRect.height) |
| 76 | + (!isSimilarValue(preRect.width, sourceRect.width) || !isSimilarValue(preRect.height, sourceRect.height)) |
77 | 77 | ) { |
78 | 78 | reAlign = true; |
79 | 79 | } |
@@ -121,11 +121,16 @@ export default { |
121 | 121 | const element = getElement(target); |
122 | 122 | const point = getPoint(target); |
123 | 123 |
|
| 124 | + // IE lose focus after element realign |
| 125 | + // We should record activeElement and restore later |
| 126 | + const activeElement = document.activeElement; |
| 127 | + |
124 | 128 | if (element) { |
125 | 129 | result = alignElement(source, element, align); |
126 | 130 | } else if (point) { |
127 | 131 | result = alignPoint(source, point, align); |
128 | 132 | } |
| 133 | + restoreFocus(activeElement, source); |
129 | 134 | this.aligned = true; |
130 | 135 | this.$listeners.align && this.$listeners.align(source, result); |
131 | 136 | } |
|
0 commit comments