Skip to content

problem about the node's partial selected status #2

@xueyuncheng

Description

@xueyuncheng

for example.

node's partial selected status.

- L1 (got false, wanted true)
    - L1.1 true
        - L1.1.1 checked
        - L1.1.2 not checked

according to this code snippet

// nodePartialSelected 判断节点的半选中状态
func nodePartialSelected(trees []Tree) bool {
	selectedNum := 0
	for _, v := range trees {
		if v.Selected {
			selectedNum++
		}
	}
	if selectedNum == len(trees) || selectedNum == 0 {
		// 子节点全选中,或一个也没有选中
		return false
	}
	return true
}

Proposed code snippet.
When we saw one partial selected is true, return true imediately.

// nodePartialSelected 判断节点的半选中状态
func nodePartialSelected(trees []Tree) bool {
	selectedNum := 0
	for _, v := range trees {
		if v.PartialSelected {
			return true
		}

		if v.Selected {
			selectedNum++
		}
	}

	if selectedNum == len(trees) || selectedNum == 0 {
		// 子节点全选中,或一个也没有选中
		return false
	}
	return true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions