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

Test tree checkbox API #183549

Closed
2 tasks done
alexr00 opened this issue May 26, 2023 · 5 comments
Closed
2 tasks done

Test tree checkbox API #183549

alexr00 opened this issue May 26, 2023 · 5 comments

Comments

@alexr00
Copy link
Member

alexr00 commented May 26, 2023

Refs: #116141

Complexity: 5
Roles: Developer, Engineering Manager

Create Issue


Tree items support an optional checkbox with this API proposal:

export class TreeItem2 extends TreeItem {
/**
* {@link TreeItemCheckboxState TreeItemCheckboxState} of the tree item.
* {@link TreeDataProvider.onDidChangeTreeData onDidChangeTreeData} should be fired when {@link TreeItem2.checkboxState checkboxState} changes.
*/
checkboxState?: TreeItemCheckboxState | { readonly state: TreeItemCheckboxState; readonly tooltip?: string; readonly accessibilityInformation?: AccessibilityInformation };
}

To verify, you'll need to use this checkbox property in a tree view. If you don't have an extension that could benefit from having checkboxes, you can use the tree view sample and add the checkbox property here:

https://github.com/microsoft/vscode-extension-samples/blob/f7b27a91779e770b8f8f0e6791bcefc5d9c64035/tree-view-sample/src/testView.ts#L77-L81

And listen for the checkbox change event on this tree view:

https://github.com/microsoft/vscode-extension-samples/blob/f7b27a91779e770b8f8f0e6791bcefc5d9c64035/tree-view-sample/src/testView.ts#L6-L7

Things to verify:

  • Verify that by default, if you check the checkbox of a node with children, the children get checked. Verify that when you check all children, the parent gets checked. Also verify that you see this reflected in the onDidChangeCheckboxState.
  • Verify that if you set the manuallyManageCheckboxSelection option (
    /**
    * By default, when the children of a tree item have already been fetched, child checkboxes are automatically managed based on the checked state of the parent tree item.
    * If the tree item is collapsed by default (meaning that the children haven't yet been fetched) then child checkboxes will not be updated.
    * To override this behavior and manage child and parent checkbox state in the extension, set this to `true`.
    */
    manuallyManageCheckboxSelection?: boolean;
    ) that you do not see the children and parents get automatically checked as described in the previous point.
  • Verify that the JS Doc comments make sense.
  • Verify that the checkbox tool tip and accessibility information are applied in the way you'd expect.
@TylerLeonhardt
Copy link
Member

Feels really nice! Excited for finalization so I can adopt it completely 😄

@aeschli
Copy link
Contributor

aeschli commented May 31, 2023

There's no API to set the checked state programmatically, correct?

@TylerLeonhardt
Copy link
Member

@aeschli I was using a tree data provider by setting the checked state on the TreeItem, then firing the did change event. This allowed me to programmatically set an item as checked/unchecked.

@meganrogge
Copy link
Contributor

I think this should be closed, reopen if I'm wrong

@alexr00
Copy link
Member Author

alexr00 commented May 31, 2023

Using a tree data provider and setting the checked state on the TreeItem, then firing the on did change event is the way to set the checked state programmatically.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants