Skip to content

Commit 144ab57

Browse files
committed
fix(modal): height calc error #161
1 parent 8d7d083 commit 144ab57

File tree

26 files changed

+162
-112
lines changed

26 files changed

+162
-112
lines changed

CHANGELOG.zh_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- 恢复 table 的`isTreeTable`属性
1414
- 修复表格内存溢出问题
1515
- 修复`layout` 收缩展开功能在分割模式下失效
16+
- 修复 modal 高度计算错误
1617

1718
## 2.0.0-rc.15 (2020-12-31)
1819

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ yarn clean:lib # 删除node_modules,兼容window系统
256256

257257
如果这些插件对你有帮助,可以给一个 star 支持下
258258

259-
- [vite-plugin-mock](https://github.com/anncwb/vite-plugin-mock)
260-
- [vite-plugin-html](https://github.com/anncwb/vite-plugin-html)
259+
- [vite-plugin-mock](https://github.com/vbenjs/vite-plugin-mock)
260+
- [vite-plugin-html](https://github.com/vbenjs/vite-plugin-html)
261261

262262
## 加入我们
263263

src/components/Basic/src/BasicArrow.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
1616
export default defineComponent({
1717
name: 'BasicArrow',
18+
inheritAttrs: false,
1819
components: { RightOutlined },
1920
props: {
2021
// Expand contract, expand by default

src/components/Basic/src/BasicHelp.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import { useDesign } from '/@/hooks/web/useDesign';
1313
export default defineComponent({
1414
name: 'BasicHelp',
15+
inheritAttrs: false,
1516
components: { Tooltip },
1617
props: {
1718
// max-width

src/components/Basic/src/BasicTitle.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
1616
export default defineComponent({
1717
name: 'BasicTitle',
18+
inheritAttrs: false,
1819
components: { BasicHelp },
1920
props: {
2021
helpMessage: {

src/components/Container/src/LazyContainer.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
3636
export default defineComponent({
3737
name: 'LazyContainer',
38+
inheritAttrs: false,
3839
components: { Skeleton },
3940
props: {
4041
// Waiting time, if the time is specified, whether visible or not, it will be automatically loaded after the specified time

src/components/Container/src/ScrollContainer.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
export default defineComponent({
1414
name: 'ScrollContainer',
15+
inheritAttrs: false,
1516
components: { Scrollbar },
1617
setup() {
1718
const scrollbarRef = ref<Nullable<ScrollbarType>>(null);

src/components/Markdown/src/index.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
99
import { propTypes } from '/@/utils/propTypes';
1010
import { useLocale } from '/@/hooks/web/useLocale';
11+
import { useModalContext } from '../../Modal';
1112
1213
type Lang = 'zh_CN' | 'en_US' | 'ja_JP' | 'ko_KR' | undefined;
1314
export default defineComponent({
14-
emits: ['change'],
15+
inheritAttrs: false,
1516
props: {
1617
height: propTypes.number.def(360),
1718
value: propTypes.string.def(''),
1819
},
20+
emits: ['change', 'get'],
1921
setup(props, { attrs, emit }) {
2022
const wrapRef = ref<ElRef>(null);
2123
const vditorRef = ref<Nullable<Vditor>>(null);
2224
const initedRef = ref(false);
2325
26+
const modalFn = useModalContext();
27+
2428
const lang = ref<Lang>();
2529
2630
const { getLang } = useLocale();
@@ -66,10 +70,19 @@
6670
initedRef.value = true;
6771
}
6872
73+
const instance = {
74+
getVditor: (): Vditor => vditorRef.value!,
75+
};
76+
6977
onMounted(() => {
7078
nextTick(() => {
7179
init();
80+
setTimeout(() => {
81+
modalFn?.redoModalHeight?.();
82+
}, 200);
7283
});
84+
85+
emit('get', instance);
7386
});
7487
7588
onUnmounted(() => {
@@ -82,7 +95,7 @@
8295
8396
return {
8497
wrapRef,
85-
getVditor: (): Vditor => vditorRef.value!,
98+
...instance,
8699
};
87100
},
88101
});

src/components/Modal/src/BasicModal.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
:height="getProps.height"
2828
:visible="visibleRef"
2929
:modalFooterHeight="footer !== undefined && !footer ? 0 : undefined"
30-
v-bind="omit(getProps.wrapperProps, 'visible')"
30+
v-bind="omit(getProps.wrapperProps, 'visible', 'height')"
3131
@ext-height="handleExtHeight"
3232
@height-change="handleHeightChange"
3333
>
@@ -51,6 +51,7 @@
5151
watchEffect,
5252
toRef,
5353
getCurrentInstance,
54+
nextTick,
5455
} from 'vue';
5556
5657
import Modal from './components/Modal';
@@ -67,6 +68,7 @@
6768
import { omit } from 'lodash-es';
6869
export default defineComponent({
6970
name: 'BasicModal',
71+
inheritAttrs: false,
7072
components: { Modal, ModalWrapper, ModalClose, ModalFooter, ModalHeader },
7173
props: basicProps,
7274
emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register'],

src/components/Modal/src/components/ModalWrapper.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
3232
export default defineComponent({
3333
name: 'ModalWrapper',
34+
inheritAttrs: false,
3435
components: { Spin, ScrollContainer },
3536
props: {
3637
loading: propTypes.bool,
@@ -51,6 +52,8 @@
5152
const realHeightRef = ref(0);
5253
const minRealHeightRef = ref(0);
5354
55+
let realHeight = 0;
56+
5457
let stopElResizeFn: Fn = () => {};
5558
5659
useWindowSizeFn(setModalHeight);
@@ -137,8 +140,9 @@
137140
138141
if (!spinEl) return;
139142
140-
const realHeight = spinEl.scrollHeight;
141-
143+
if (!realHeight) {
144+
realHeight = spinEl.scrollHeight;
145+
}
142146
if (props.fullScreen) {
143147
realHeightRef.value =
144148
window.innerHeight - props.modalFooterHeight - props.modalHeaderHeight;
@@ -147,7 +151,7 @@
147151
? props.height
148152
: realHeight > maxHeight
149153
? maxHeight
150-
: realHeight + 16 + 30;
154+
: realHeight + 46;
151155
}
152156
emit('height-change', unref(realHeightRef));
153157
} catch (error) {

0 commit comments

Comments
 (0)