Skip to content

Commit d66abd3

Browse files
author
Kenneth Cheng
committed
Fixed multi-values of badge bgcolor crash issue
1 parent abbf0e4 commit d66abd3

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
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.37",
5+
"version": "1.0.38",
66
"main": "src/main.js",
77
"dependencies": {
88
"@vuepic/vue-datepicker": "^3.3.0",

src/VueExcelColumn.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ export default {
117117
case 'action':
118118
return this.placeholder || ''
119119
case 'badge':
120-
return `<span class='badge'>${val}</span>`
120+
if (this.bgcolor) {
121+
let bgcolor = this.bgcolor
122+
if (typeof bgcolor == 'function') bgcolor = bgcolor(val)
123+
return `<span class='badge' style='background-color:${bgcolor}'>${val}</span>`
124+
}
125+
else
126+
return `<span class='badge'>${val}</span>`
121127
default:
122128
return val
123129
}

src/VueExcelEditor.vue

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -919,11 +919,9 @@ export default defineComponent({
919919
renderColumnCellStyle (field, record) {
920920
let result = field.initStyle
921921
if (field.readonly) result = Object.assign(result, this.readonlyStyle)
922-
if (field.left) result = Object.assign(result, {left: field.left})
923-
if (record && field.bgcolor)
924-
result = Object.assign(result, {'--bgcolor': typeof field.bgcolor === 'function' ? field.bgcolor(record) : field.bgcolor })
922+
if (field.left) result.left = field.left
925923
if (record && field.color)
926-
result = Object.assign(result, {'--color': typeof field.color === 'function' ? field.color(record) : field.color })
924+
result.color = (typeof field.color === 'function' ? field.color(record) : field.color)
927925
return result
928926
},
929927
localeDate (d) {
@@ -2260,18 +2258,21 @@ export default defineComponent({
22602258
mouseDown (e) {
22612259
if (e.target.parentNode.parentNode.tagName === 'TBODY' && !e.target.classList.contains('first-col')) {
22622260
e.preventDefault()
2263-
setTimeout(() => this.inputBox.focus())
2264-
this.focused = true
22652261
const row = e.target.parentNode
22662262
const colPos = Array.from(row.children).indexOf(e.target) - 1
22672263
const rowPos = Array.from(row.parentNode.children).indexOf(row)
22682264
this.currentField = this.fields[colPos]
2265+
this.currentCell = row.children[colPos + 1]
22692266
this.$emit('cell-click', {rowPos, colPos})
22702267
if (typeof this.currentField.cellClick === 'function')
22712268
this.currentField.cellClick(this.currentCell.textContent, this.currentRecord, rowPos, colPos, this.currentField, this)
2272-
this.moveInputSquare(rowPos, colPos)
22732269
if (this.currentField && this.currentField.link /* && e.altKey */ && this.currentCell.textContent)
2274-
setTimeout(() => this.currentField.link(this.currentCell.textContent, this.currentRecord, rowPos, colPos, this.currentField, this))
2270+
return setTimeout(() => this.currentField.link(this.currentCell.textContent, this.currentRecord, rowPos, colPos, this.currentField, this))
2271+
2272+
setTimeout(() => this.inputBox.focus())
2273+
this.focused = true
2274+
this.moveInputSquare(rowPos, colPos)
2275+
22752276
if (this.currentField.listByClick) return this.calAutocompleteList(true)
22762277
if (e.target.offsetWidth - e.offsetX > 25) return
22772278
if (e.target.offsetWidth < e.target.scrollWidth) {
@@ -2986,13 +2987,11 @@ input:focus, input:active:focus, input.active:focus {
29862987
white-space: nowrap;
29872988
overflow-x: hidden;
29882989
text-overflow: ellipsis;
2989-
color: var(--color);
29902990
/* animation: fadein 0.2s; */
29912991
}
29922992
.systable tbody td :deep(.badge) {
29932993
padding: 0px 10px;
29942994
border-radius: 10px;
2995-
background-color: var(--bgcolor);
29962995
font-weight: 400;
29972996
}
29982997

0 commit comments

Comments
 (0)