Skip to content

Commit

Permalink
fix(table): issue: element-plus#505 (element-plus#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
justwiner authored Oct 30, 2020
1 parent 212f161 commit 498f327
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/table/src/store/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ function useWatcher() {
updateColumns()
}
if (immediate) {
instance.vnode.state.doLayout()
instance.state.doLayout()
} else {
instance.vnode.state.debouncedUpdateLayout()
instance.state.debouncedUpdateLayout()
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/table-header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default defineComponent({
} = useStyle(props)
const { isGroup, toggleAllSelection, columnRows } = useUtils(props)

instance.vnode.state = {
instance.state = {
onColumnsChange,
onScrollableChange,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/table-header/utils-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function useUtils(props: TableHeaderProps) {
})
const isGroup = computed(() => {
const result = columnRows.value.length > 1
if (result) parent.vnode.state.isGroup.value = true
if (result) parent.state.isGroup.value = true
return result
})
const toggleAllSelection = (event: Event) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/table/src/table-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class TableLayout {
}

this.bodyWidth.value = Math.max(bodyMinWidth, bodyWidth)
this.table.vnode.state.resizeState.value.width = this.bodyWidth.value
this.table.state.resizeState.value.width = this.bodyWidth.value
} else {
flattenColumns.forEach(column => {
if (!column.width && !column.minWidth) {
Expand Down Expand Up @@ -298,10 +298,10 @@ class TableLayout {
observers.forEach(observer => {
switch (event) {
case 'columns':
observer.vnode.state?.onColumnsChange(this)
observer.state?.onColumnsChange(this)
break
case 'scrollable':
observer.vnode.state?.onScrollableChange(this)
observer.state?.onScrollableChange(this)
break
default:
throw new Error(`Table Layout don't have event ${event}.`)
Expand Down
16 changes: 6 additions & 10 deletions packages/table/src/table.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ interface TableRefs {
[key: string]: unknown
}

interface TableVnodeState {
interface TableState {
isGroup: Ref<boolean>
resizeState: Ref<{
width: any
Expand All @@ -289,18 +289,14 @@ interface Table extends ComponentInternalInstance {
layout: TableLayout
refs: TableRefs
tableId: string
vnode: VNode & {
state: TableVnodeState
}
state: TableState
}

interface TableHeader extends ComponentInternalInstance {
vnode: {
state: {
onColumnsChange
onScrollableChange
}
} & VNode
state: {
onColumnsChange
onScrollableChange
}
filterPanels: Ref<AnyObject>
}

Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export default defineComponent({
const tableId = 'el-table_' + tableIdSeed++
table.tableId = tableId
table.vnode.state = {
table.state = {
isGroup,
resizeState,
doLayout,
Expand Down

0 comments on commit 498f327

Please sign in to comment.