Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MudTreeviewItem: Fix checkbox in multi-selection mode #8948

Merged
merged 2 commits into from
May 11, 2024

Conversation

henon
Copy link
Collaborator

@henon henon commented May 11, 2024

Resolves #8940

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

@github-actions github-actions bot added bug Something does not work as intended/expected PR: needs review labels May 11, 2024
Copy link

codecov bot commented May 11, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 90.47%. Comparing base (28bc599) to head (b92666a).
Report is 180 commits behind head on dev.

Files Patch % Lines
...lazor/Components/TreeView/MudTreeViewItem.razor.cs 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #8948      +/-   ##
==========================================
+ Coverage   89.82%   90.47%   +0.64%     
==========================================
  Files         412      419       +7     
  Lines       11878    12192     +314     
  Branches     2364     2380      +16     
==========================================
+ Hits        10670    11031     +361     
+ Misses        681      628      -53     
- Partials      527      533       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@henon henon requested a review from ScarletKuro May 11, 2024 14:03
@henon henon changed the title MudTreeviewItem: Fix checkboxe in multi-selection mode MudTreeviewItem: Fix checkbox in multi-selection mode May 11, 2024
@ScarletKuro ScarletKuro merged commit 57f2e6a into MudBlazor:dev May 11, 2024
4 of 5 checks passed
@Yomodo
Copy link
Contributor

Yomodo commented May 11, 2024

@henon I found 2 more issue, clicking the first node skips the nested subitems node:

image

Multi selection:
Selecting all now shows indeterminate state:

image

@ScarletKuro
Copy link
Member

@henon do we reopen this issue or shall we create new one?

@henon
Copy link
Collaborator Author

henon commented May 12, 2024

No need, I'll directly PR a fix

@henon
Copy link
Collaborator Author

henon commented May 13, 2024

Multi selection: Selecting all now shows indeterminate state:

image

This is intended behavior, you shouldn't confuse this example with the custom logic one. Here selecting the parent just selects it and not its children. Conversely selecting all its children doesn't automatically select the parent. That is exactly why we have the custom checkbox example to show how to implement this feature if required

@henon
Copy link
Collaborator Author

henon commented May 13, 2024

OK, sorry @Yomodo nevermind what I said above, selection should select children and vice versa. There is a bug in there, I can reproduce it. Whether it happens, depends on whether or not the parent was selected.

@henon
Copy link
Collaborator Author

henon commented May 13, 2024

OK, flip-flopping back to the original statement, it isn't a bug, it is just very confusing that's all. The thing causing the confusion in this example is the fact that a directory has its own selected state which does not depend on the selection of its children. So when the parent is checked off, and you check all children, then the parent will remain unchecked for TriState=false
image

and indeterminate for TriState=true
image

When the parent is checked and children are not all checked: TriState=false
image

When the parent is checked and children are not all checked: TriState=true
image

This behavior is intended but I realize it isn't very consistent. Checking the parent automatically checks all children but unchecking a child doesn't update the parent state. I will change it. Then I guess we don't need the custom logic example any longer as the treeview will behave like it automatically.

@Yomodo
Copy link
Contributor

Yomodo commented May 13, 2024

Thank you for explaining; it all makes sense now.

@henon
Copy link
Collaborator Author

henon commented May 13, 2024

I implemented the expected change in behavior so that checking/unchecking children updates the parent.

treeview hierarchic selection

And I removed the custom checkbox example as it makes no sense any longer.

@henon
Copy link
Collaborator Author

henon commented May 13, 2024

Just note that modifying the selection via SelectedValues does not trigger any hierarchic selection like when you click the checkboxes. So for instance, if you select only bundle.zip in the chipset and leave everything else off, it will not cause all subtrees to become selected. I hope that is ok.

@henon
Copy link
Collaborator Author

henon commented May 13, 2024

@Yomodo: see PR #8957

@Yomodo
Copy link
Contributor

Yomodo commented May 13, 2024

Yes, with correct use of the TriState property, it's now exactly as (I) expected. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: TreeView parent checkbox gets unchecked when all subitems are checked
3 participants