Skip to content

Allow TreeItems to have optional checkboxes #116141

Description

@TylerLeonhardt

I'm all for trying to avoid webviews as much as possible, especially when tree views are hard to make work in a webview. This proposal allows for treeviews to have checkboxes:

image
(but better styling of course 😄)

Scenarios

  • To-do list extensions
  • Applying filters where an 'Edit' button drops you into the experience above where checkboxes show up
  • Crafting .gitignore's or other 'ignores' where you go down the filesystem and uncheck the files you want to ignore

Proposal

  • TreeItem has new optional property called checkboxState similar to collapsibleState which takes in a TreeItemCheckBoxState:
        export class TreeItem {
            // ...

            /**
             * [TreeItemCheckboxState](#TreeItemCheckboxState) of the tree item.
             */
            checkboxState?: TreeItemCheckboxState;

            // ...
        }

       /**
	 * Checkbox state of the tree item
	 */
        export enum TreeItemCheckboxState{
		/**
		 * Determines an item can be neither checked nor unchecked. Implies it has no checkbox.
		 */
		None = 0,
		/**
		 * Determines an item is checked
		 */
		Checked = 1,
		/**
		 * Determines an item is unchecked
		 */
		Unchecked = 2
	}
  • TreeDataProvider will have a new optional event onDidChangeTreeCheckbox which will fire when the checkbox of a TreeItem is checked or unchecked:
        /**
	 * A data provider that provides tree data
	 */
	export interface TreeDataProvider<T> {
                // ...

                /**
		 * An optional event to signal that an element or root has either been checked or unchecked.
		 */
		onDidChangeTreeCheckbox?: Event<ChangeTreeCheckboxEvent<T>>;

                // ...
        }

        export interface ChangeTreeCheckboxEvent {
                /**
		 * The item that was checked or unchecked.
		 */
		readonly item: <T>;

		/**
		 * Removed workspace folders.
		 */
		readonly newState: TreeItemCheckboxState;
        }

Activity

  1. added
    tree-widget
    feature-request
    on Feb 8, 2021
  2. TylerLeonhardt commented on Feb 8, 2021

    @TylerLeonhardt
    MemberAuthor

    btw, this is essentially an alternative to #115365

  3. vscode-triage-bot commented on Feb 8, 2021

    @vscode-triage-bot

    This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  4. vscode-triage-bot commented on Feb 9, 2021

    @vscode-triage-bot

    This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  5. vscode-triage-bot commented on Apr 1, 2021

    @vscode-triage-bot

    This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  6. removed this from the Backlog Candidates milestone on Apr 1, 2021
  7. 37 remaining items

  8. alexr00 commented on May 25, 2023

    @alexr00
    Member

    Thanks for the example Yan Zhang (@Eskibear)! I was using the readonly state: TreeItemCheckboxState; readonly tooltip?: string;} type for checkboxState, which is why I failed to repro.

  9. added a commit that references this issue on Jun 22, 2023
    95a6cd8
  10. added a commit that references this issue on Jun 22, 2023
    f5fccbd
  11. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Jun 22, 2023
  12. locked and limited conversation to collaborators on Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-finalizationfeature-requestinsiders-releasedon-testplantree-views

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions