Skip to content

Commit d383fe2

Browse files
authored
navigator: updated styling for children of root nodes (#11967)
The commit updates the styling for children root nodes in file-tree-widgets so that they include additional padding compared to the root which is often displayed as a tree-view section. The change helps more easily identify the hierarchy of the tree.
1 parent f94ad05 commit d383fe2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/core/src/browser/tree/tree-widget.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
862862
} else {
863863
classNames.push(renderIndentGuides === 'onHover' ? 'hover' : 'always');
864864
}
865-
const paddingLeft = this.props.leftPadding * depth;
865+
const paddingLeft = this.getDepthPadding(depth);
866866
indentDivs.unshift(<div key={depth} className={classNames.join(' ')} style={{
867867
paddingLeft: `${paddingLeft}px`
868868
}} />);
@@ -969,7 +969,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
969969
}
970970

971971
protected getPaddingLeft(node: TreeNode, props: NodeProps): number {
972-
return props.depth * this.props.leftPadding + (this.needsExpansionTogglePadding(node) ? this.props.expansionTogglePadding : 0);
972+
return this.getDepthPadding(props.depth) + (this.needsExpansionTogglePadding(node) ? this.props.expansionTogglePadding : 0);
973973
}
974974

975975
/**
@@ -1419,7 +1419,9 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
14191419
protected toNodeDescription(node: TreeNode): string {
14201420
return this.labelProvider.getLongName(node);
14211421
}
1422-
1422+
protected getDepthPadding(depth: number): number {
1423+
return depth * this.props.leftPadding;
1424+
}
14231425
}
14241426
export namespace TreeWidget {
14251427
/**

packages/filesystem/src/browser/file-tree/file-tree-widget.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,8 @@ export class FileTreeWidget extends CompressedTreeWidget {
315315
return inflated;
316316
}
317317

318+
protected override getDepthPadding(depth: number): number {
319+
// add additional depth so file nodes are rendered with padding in relation to the top level root node.
320+
return super.getDepthPadding(depth + 1);
321+
}
318322
}

0 commit comments

Comments
 (0)