Skip to content

Commit

Permalink
fix: merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbing4 committed Aug 13, 2024
2 parents 5578690 + 4cb90e3 commit 556a419
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 24 deletions.
3 changes: 1 addition & 2 deletions components/select/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ export abstract class BaseSelect<
e.stopPropagation();
const {value, multiple} = this.get();
const immutableValues = this.immutable.immutableValues.value;

this.set('value', multiple ? (Array.isArray(value) ? value.filter(key => immutableValues.includes(key)) : []) : null);

this.set('value', multiple ? (Array.isArray(value) ? value.filter(key => immutableValues.includes(key)) : []) : null);
}

@bind
Expand Down
36 changes: 22 additions & 14 deletions components/table/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {bind} from '../utils';
import type {TableGrid} from './useMerge';
import { isEqualObject } from '../utils';
import { useConfigContext } from '../config';
import { hasOwn } from 'intact-shared';

export interface TableRowProps {
key: TableRowKey
Expand Down Expand Up @@ -66,20 +67,27 @@ export class TableRow extends Component<TableRowProps> {
const nextProps = nextVNode.props as TableRowProps;

let isSame = true;
let key: keyof TableRowProps;
for (key in lastProps) {
// ignore index
if (key === 'index') continue;
const lastValue = lastProps[key];
const nextValue = nextProps[key];
// deeply compare for offsetMap
if (key === 'offsetMap' && isEqualObject(lastValue, nextValue)) {
continue;
}

if (lastValue !== nextValue) {
isSame = false;
break;
if (hasOwn.call(this, 'vueInstance')) {
// In Vue, we may change value by modifing the same reference,
// and the new row may be expanded by click tree arrow
// so we can not compare in this case, #1030
isSame = false;
} else {
let key: keyof TableRowProps;
for (key in lastProps) {
// ignore index
if (key === 'index') continue;
const lastValue = lastProps[key];
const nextValue = nextProps[key];
// deeply compare for offsetMap
if (key === 'offsetMap' && isEqualObject(lastValue, nextValue)) {
continue;
}

if (lastValue !== nextValue) {
isSame = false;
break;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/table/useGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function useGroup() {

function isEmptyValue(groupValue: any) {
const {multiple} = instance.get();
return !groupValue || multiple && (!isArray(groupValue) || groupValue.every(value => !value));
return (!groupValue && groupValue !== 0) || multiple && (!isArray(groupValue) || groupValue.every(value => !value));
}

watchState(keywords, (v) => {
Expand Down
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* @king-design v3.4.3-beta.0
* @king-design v3.4.3-beta.2
*
* Copyright (c) Kingsoft Cloud
* Released under the MIT License
Expand Down Expand Up @@ -69,6 +69,6 @@ export * from './components/upload';
export * from './components/view';
export * from './components/wave';

export const version = '3.4.3-beta.0';
export const version = '3.4.3-beta.2';

/* generate end */
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"./",
"packages/*"
],
"version": "3.4.3-beta.0",
"version": "3.4.3-beta.2",
"npmClient": "yarn"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@king-design/intact",
"version": "3.4.3-beta.0",
"version": "3.4.3-beta.2",
"description": "A component library written in Intact for Intact, Vue, React and Angular",
"main": "es/index.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kpc-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@king-design/react",
"version": "3.4.3-beta.0",
"version": "3.4.3-beta.2",
"description": "King-Design UI components for React.",
"keywords": [
"component",
Expand Down
54 changes: 54 additions & 0 deletions packages/kpc-vue-next/__tests__/components/table.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {createApp, render} from 'vue';
import {mount, unmount, dispatchEvent, getElement, wait} from '@/test/utils';
import {Table, TableColumn, Input} from '../../';

describe('Table', () => {
it('should update Input in children rows', async () => {
const container = document.createElement('div');
document.body.appendChild(container);
const vue = createApp({
template: `
<Table ref="table" :data="data" checkType="none">
<TableColumn key="discount" title="折扣">
<template v-slot="[data]">
<Input v-model="data.discount" />
</template>
</TableColumn>
</Table>
`,
components: {
Table, TableColumn, Input
},
data() {
return {
data: [
{
discount: "3.5",
children: [
{
discount: "4.5",
},
],
},
],
}
}
}).mount(container);

const table = vue.$refs.table as Table;
table.set('spreadKeys', [0]);
await wait();

const [, input] = document.querySelectorAll('input');
dispatchEvent(input, 'focus');
input.value = 'a';
dispatchEvent(input, 'input')
dispatchEvent(input, 'blur');

await wait();
expect(input.value).to.eql('a');

render(null, container);
document.body.removeChild(container);
});
});
2 changes: 1 addition & 1 deletion packages/kpc-vue-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@king-design/vue",
"version": "3.4.3-beta.0",
"version": "3.4.3-beta.2",
"description": "King-Design UI components for Vue3.0.",
"keywords": [
"component",
Expand Down
2 changes: 1 addition & 1 deletion packages/kpc-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@king-design/vue-legacy",
"version": "3.4.3-beta.0",
"version": "3.4.3-beta.2",
"description": "King-Design UI components for Vue2.0.",
"keywords": [
"component",
Expand Down

0 comments on commit 556a419

Please sign in to comment.