Skip to content
This repository was archived by the owner on Jan 1, 2025. It is now read-only.
This repository was archived by the owner on Jan 1, 2025. It is now read-only.

Toggling checkbox of parent does not toggle checkbox of all children #115

@bruceceng

Description

@bruceceng

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • I'm submitting a ...

    • bug report
    • feature request
    • support request => Please do not submit support request here, see note at the top of this template.
  • Do you want to request a feature or report a bug?

Report a bug

  • What is the current behavior?

In the sandbox demo provided, clicking the "Animal" checkbox should cause the Dog checkbox to become checked. Right now, only the Cat checkbox and its children become checked.

Open the demo and click the checkbox next to Animal

  • What is the expected behavior?

The Dog check box should be checked.

  • What is the motivation / use case for changing the behavior?

That's how trees are supposed to work.

  • Please tell us about your environment:

    • Version: 2.0.0-beta.X
    • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    • Language: [all | TypeScript X.X | ES6/7 | ES5 | Dart]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

To fix it, you should modify function updateChildNodeStatus. There is a statement: const currentNode = {...item, checked, }; which temporarily sets the checked state of Dog, but this is later overridden by the nodeUpdate triggered in the computed filteredData. If you instead mutate the item by adding: item.checked = checked; after this line it appears to correct the problem. However, I should note that when testing this fix, I was passing a reactive tree object, so I'm not positive this will fix the behavior in your demo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions