Skip to content

Allow TreeItems to have optional checkboxes #116141

@TylerLeonhardt

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;
        }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions