feat(amis): 子节点包含部分选中状态时,父节点也标记为部分选中

避免父节点是部分选中而祖先节点是未选中状态的问题
This commit is contained in:
ranqirong 2023-11-15 15:01:17 +08:00
parent 5108906e96
commit 2808790a96
3 changed files with 9 additions and 3 deletions

View File

@ -107,7 +107,7 @@ describe('TableStore', () => {
expect(secondLevel2.checked).toBe(false);
expect(secondLevel2.partial).toBe(true);
expect(firstLevel.partial).toBe(false);
expect(firstLevel.checked).toBe(false);
expect(firstLevel.partial).toBe(true);
});
});

View File

@ -226,7 +226,13 @@ export const Row = types
},
get partial(): boolean {
return this.childrenSelected() === SELECTED_STATUS.PARTIAL;
const childrenSelected =
this.childrenSelected() === SELECTED_STATUS.PARTIAL;
const childrenPartial = (self as IRow).children.some(
(child: IRow) => child.partial
);
return childrenSelected || childrenPartial;
},
get checked(): boolean {

View File

@ -7,7 +7,7 @@ import {
within
} from '@testing-library/react';
import {render as amisRender} from '../../../src';
import {makeEnv, wait} from '../../helper';
import {makeEnv} from '../../helper';
const items = [
{