提交 4c6741b2 编写于 作者: J Joao Moreno

expandOnlyOnTwistieClick per element

related to #62127
上级 94d424ae
......@@ -712,7 +712,7 @@ export interface IAbstractTreeOptions<T, TFilterData = void> extends IAbstractTr
readonly dnd?: ITreeDragAndDrop<T>;
readonly autoExpandSingleChildren?: boolean;
readonly keyboardNavigationEventFilter?: IKeyboardNavigationEventFilter;
readonly expandOnlyOnTwistieClick?: boolean;
readonly expandOnlyOnTwistieClick?: boolean | ((e: T) => boolean);
}
function dfs<T, TFilterData>(node: ITreeNode<T, TFilterData>, fn: (node: ITreeNode<T, TFilterData>) => void): void {
......@@ -825,7 +825,15 @@ class TreeNodeListMouseController<T, TFilterData, TRef> extends MouseController<
return super.onPointer(e);
}
if (this.tree.expandOnlyOnTwistieClick && !onTwistie) {
let expandOnlyOnTwistieClick = false;
if (typeof this.tree.expandOnlyOnTwistieClick === 'function') {
expandOnlyOnTwistieClick = this.tree.expandOnlyOnTwistieClick(node.element);
} else {
expandOnlyOnTwistieClick = !!this.tree.expandOnlyOnTwistieClick;
}
if (expandOnlyOnTwistieClick && !onTwistie) {
return super.onPointer(e);
}
......@@ -834,7 +842,7 @@ class TreeNodeListMouseController<T, TFilterData, TRef> extends MouseController<
const recursive = e.browserEvent.altKey;
model.setCollapsed(location, undefined, recursive);
if (this.tree.expandOnlyOnTwistieClick && onTwistie) {
if (expandOnlyOnTwistieClick && onTwistie) {
return;
}
......@@ -952,7 +960,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
// Options TODO@joao expose options only, not Optional<>
get openOnSingleClick(): boolean { return typeof this._options.openOnSingleClick === 'undefined' ? true : this._options.openOnSingleClick; }
get expandOnlyOnTwistieClick(): boolean { return typeof this._options.expandOnlyOnTwistieClick === 'undefined' ? false : this._options.expandOnlyOnTwistieClick; }
get expandOnlyOnTwistieClick(): boolean | ((e: T) => boolean) { return typeof this._options.expandOnlyOnTwistieClick === 'undefined' ? false : this._options.expandOnlyOnTwistieClick; }
get onDidDispose(): Event<void> { return this.view.onDidDispose; }
......
......@@ -217,7 +217,12 @@ function asObjectTreeOptions<TInput, T, TFilterData>(options?: IAsyncDataTreeOpt
return options.keyboardNavigationLabelProvider!.getKeyboardNavigationLabel(e.element as T);
}
},
sorter: undefined
sorter: undefined,
expandOnlyOnTwistieClick: typeof options.expandOnlyOnTwistieClick === 'undefined' ? undefined : (
typeof options.expandOnlyOnTwistieClick !== 'function' ? options.expandOnlyOnTwistieClick : (
e => (options.expandOnlyOnTwistieClick as ((e: T) => boolean))(e.element as T)
)
)
};
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册