Skip to content

Commit b477a37

Browse files
author
Kenneth Cheng
committed
correct the auto-fill-width
1 parent 5e04c48 commit b477a37

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue3-excel-editor",
33
"email": "apple.6502@gmail.com",
44
"description": "Vue3 plugin for displaying and editing the array-of-object in Excel style",
5-
"version": "1.0.52",
5+
"version": "1.0.54",
66
"main": "src/main.js",
77
"dependencies": {
88
"@vuepic/vue-datepicker": "^3.3.0",

src/VueExcelEditor.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,14 +1103,14 @@ export default defineComponent({
11031103
const count = doFields.length
11041104
if (!count) return
11051105
1106-
setTimeout(() => {
1107-
const fullWidth = this.editor.getBoundingClientRect().width
1108-
let viewWidth = this.fields.filter(f => !f.invisible).reduce((c, f) => c - -f.width.replace(/px$/, ''), 0)
1106+
this.lazy(() => {
1107+
let fullWidth = this.editor.getBoundingClientRect().width
1108+
let viewWidth = this.fields.filter(f => !f.invisible).reduce((c, f) => c + parseFloat(f.width), 0)
11091109
viewWidth += this.numColWidth
1110-
if (this.tableContent.scrollHeight > this.tableContent.clientHeight) viewWidth += 13
1110+
if (this.vScroller.buttonHeight < this.vScroller.height) fullWidth -= 13
11111111
const fillWidth = viewWidth - fullWidth + 2
1112-
if (fillWidth)
1113-
doFields.forEach(f => f.width = (f.width.replace(/px$/, '') - fillWidth / count) + 'px')
1112+
if (Math.abs(fillWidth) > 1)
1113+
doFields.forEach(f => f.width = (parseFloat(f.width) - fillWidth / count) + 'px')
11141114
})
11151115
},
11161116
@@ -2771,6 +2771,13 @@ export default defineComponent({
27712771
if (selector) selector.classList.remove('error')
27722772
}
27732773
},
2774+
validateAll() {
2775+
this.errmsg = {}
2776+
this.rowerr = {}
2777+
return Promise.all(this.table.map(row =>
2778+
Promise.all(Object.keys(row).map(name => this.updateCell(row, name, row[name], false))
2779+
)))
2780+
},
27742781
27752782
/* *** Autocomplete ****************************************************************************************
27762783
*/

0 commit comments

Comments
 (0)