mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[TreeView] Automatic parents and children selection

Open flaviendelangle opened this issue 1 year ago • 8 comments

No rush to review this PR since it's not for v7, breaking change preparations on the pickers are more pressing :pray:

Apply #13757 for the Tree View Closes #12883 Doc preview

Thanks to @MBilalShafi for all the work on the Data Grid feature, porting it to the Tree View is a piece of cake now :pray:

There is a super small BC on the legacy TreeItem, I propose to keep the feature for the alpha, it will be the main new feature for the Tree View in the stablefor people without big datasets.

  • [x] Build feature
  • [x] Add doc
  • [x] Add tests
  • [x] Move the checkbox logic from useTreeItem2 to useTreeViewSelection.itemPlugin (it's becoming quite large with the indeterminate support)
  • [x] Support indeterminate checkbox state (same behavior as the grid)

flaviendelangle avatar Oct 09 '24 15:10 flaviendelangle

Deploy preview: https://deploy-preview-14899--material-ui-x.netlify.app/

Updated pages:

Generated by :no_entry_sign: dangerJS against dfe3497ea39f6a032f18cb72b2d4331c0b75fd51

mui-bot avatar Oct 09 '24 15:10 mui-bot

@flaviendelangle Thank you for the amazing work. I have one question: If the parent checkbox is in an indeterminate state and the user checks it, shouldn’t the first click select all the children, and the second click uncheck all of them along with the parent?

Kavan72 avatar Oct 15 '24 08:10 Kavan72

Hey @Kavan72, thanks for the feedback

The action when clicking on an indeterminate parent was the source of a lot of debate over on the Data Grid. The current behavior their is to unselect all by default but have it configurable using the indeterminateCheckboxAction prop which has the following type:

  /**
   * If `select`, a group header checkbox in indeterminate state (like "Select All" checkbox)
   * will select all the rows under it.
   * If `deselect`, it will deselect all the rows under it.
   * Works only if `checkboxSelection` is enabled.
   * @default "deselect"
   */
indeterminateCheckboxAction?: 'select' | 'deselect'

On the Tree View, I followed the default behavior of the grid. We can introduce the same indeterminateCheckboxAction prop in a follow up, it should be almost trivial to do it :+1:

flaviendelangle avatar Oct 15 '24 11:10 flaviendelangle

Hey @Kavan72, thanks for the feedback

The action when clicking on an indeterminate parent was the source of a lot of debate over on the Data Grid. The current behavior their is to unselect all by default but have it configurable using the indeterminateCheckboxAction prop which has the following type:

  /**
   * If `select`, a group header checkbox in indeterminate state (like "Select All" checkbox)
   * will select all the rows under it.
   * If `deselect`, it will deselect all the rows under it.
   * Works only if `checkboxSelection` is enabled.
   * @default "deselect"
   */
indeterminateCheckboxAction?: 'select' | 'deselect'

On the Tree View, I followed the default behavior of the grid. We can introduce the same indeterminateCheckboxAction prop in a follow up, it should be almost trivial to do it 👍

That would be great feature 🙂

Kavan72 avatar Oct 15 '24 12:10 Kavan72

Issue created: #14979

Given the low complexity of the topic, I suspect that we should be able to ship that a few weeks after the main PR (depending on the bandwidth we have)

flaviendelangle avatar Oct 15 '24 13:10 flaviendelangle

For v8, on the Data Grid side, it is also one of the considerations to make select the default behavior and remove indeterminateCheckboxAction prop, mainly aiming simplicity. I'd love to decide on it together with the Tree View for consistency.

Context: 1, 2

MBilalShafi avatar Oct 15 '24 13:10 MBilalShafi

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Oct 16 '24 07:10 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Oct 17 '24 14:10 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Oct 21 '24 10:10 github-actions[bot]

Hi.

I noticed that in the preview docs the bot linked, this feature works, but it does not in the live docs.

Was there a regression? Has this simply not been released yet?

(Our support key is 65425)

ArmandRedgate avatar Nov 26 '24 13:11 ArmandRedgate

Hi,

This feature is part of the v8 alpha (which is deployed here).

flaviendelangle avatar Nov 26 '24 13:11 flaviendelangle