Skip to content

Commit

Permalink
* list: check children on self item is checked already.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Jul 23, 2024
1 parent dcf29b9 commit 1947d21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/list/src/component/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export class List<P extends ListProps = ListProps, S extends ListState = ListSta
return `.zui.${this.constructor.NAME}.list_${this.gid}`;
}

get isLazyItems() {
const {items} = this.props;
return items && !Array.isArray(items);
}

componentDidMount() {
this._afterRender(true);
this.tryLoad();
Expand All @@ -77,11 +82,11 @@ export class List<P extends ListProps = ListProps, S extends ListState = ListSta

setItems(items?: Item[], error?: Error) {
const {onLoadFail} = this.props;
this.setState({
return this.changeState({
loading: false,
items: items || [],
loadFailed: error ? (typeof onLoadFail === 'function' ? (onLoadFail as (error: Error) => CustomContentType | undefined).call(this, error as Error) : onLoadFail) || String(error) : undefined,
});
} as S);
}

load(): void {
Expand Down
8 changes: 6 additions & 2 deletions lib/list/src/component/nested-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,15 @@ export class NestedList<P extends NestedListProps = NestedListProps, S extends N
return this.props.nestedTrigger === 'hover';
}

setItems(items?: Item[] | undefined, error?: Error | undefined): void {
async setItems(items?: Item[] | undefined, error?: Error | undefined) {
if (this.isRoot) {
this._needInitChecks = true;
}
super.setItems(items, error);
const state = await super.setItems(items, error);
if (items && this.props.parent?.checked === true) {
this.toggleChecked(this._renderedItems.map(x => x.key!), true);
}
return state;
}

getItemMap() {
Expand Down

0 comments on commit 1947d21

Please sign in to comment.