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

position scrollbar for settings on far-right #56167

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

.settings-editor {
padding: 11px 24px 0px;
max-width: 1000px;
margin: auto;
}

Expand All @@ -18,6 +17,7 @@
box-sizing: border-box;
margin: auto;
overflow: hidden;
max-width: 1000px;
}

.settings-editor > .settings-header > .settings-preview-header {
Expand Down Expand Up @@ -108,7 +108,8 @@
.settings-editor > .settings-body {
display: flex;
margin: auto;
max-width: 1000px;
max-width: calc(100% - ((100% - 1000px) / 2));
margin-right: 0px;
}

.settings-editor.search-mode > .settings-body .settings-tree-container .monaco-tree-wrapper,
Expand All @@ -117,6 +118,10 @@
margin-left: 0px;
}

.settings-editor > .settings-body .settings-tree-container .scrollbar.vertical{
position: fixed !important;
}

.settings-editor.narrow > .settings-body .settings-tree-container .monaco-tree-wrapper,
.settings-editor.narrow > .settings-body > .settings-tree-container .setting-measure-container {
width: calc(100% - 11px);
Expand All @@ -126,15 +131,31 @@
.settings-editor > .settings-body .settings-tree-container .monaco-tree-wrapper,
.settings-editor > .settings-body > .settings-tree-container .setting-measure-container {
/** 11px for scrollbar + 208px for TOC margin */
width: calc(100% - 219px);
margin-left: 208px;
width: 100%;
max-width: calc( 100% - (100% - 837px));
padding-left: 160px;
}

.settings-editor.narrow > .settings-body .settings-tree-container .monaco-tree-wrapper,
.settings-editor-narrow > .settings-body > .settings-tree-container .setting-measure-container{
padding-left: 0px;
}

.settings-body .settings-tree-container {
/* makes the scrollbar itself also scrollable */
margin-right: -23px;
}

.settings-body .settings-tree-container .monaco-tree .shadow.top {
max-width: calc( 100% - (100% - 1000px));
}

.settings-editor > .settings-body .settings-toc-container {
position: absolute;
width: 160px;
margin-top: 16px;
padding-left: 5px;
order: 0;
}

.settings-editor.search-mode .settings-toc-container {
Expand Down Expand Up @@ -191,6 +212,7 @@
border-spacing: 0;
border-collapse: separate;
position: relative;
order: 1;
}

.settings-editor > .settings-body > .settings-tree-container .setting-item {
Expand Down
25 changes: 18 additions & 7 deletions src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export class SettingsEditor2 extends BaseEditor {

private rootElement: HTMLElement;
private headerContainer: HTMLElement;

private bodyContainer: HTMLElement;
private searchWidget: SuggestEnabledInput;

private settingsTargetsWidget: SettingsTargetsWidget;
private toolbar: ToolBar;

Expand Down Expand Up @@ -278,10 +281,10 @@ export class SettingsEditor2 extends BaseEditor {
}

private createBody(parent: HTMLElement): void {
const bodyContainer = DOM.append(parent, $('.settings-body'));
this.bodyContainer = DOM.append(parent, $('.settings-body'));

this.createFocusSink(
bodyContainer,
this.bodyContainer,
e => {
if (DOM.findParentWithClass(e.relatedTarget, 'settings-editor-tree')) {
if (this.settingsTree.getScrollPosition() > 0) {
Expand All @@ -300,10 +303,10 @@ export class SettingsEditor2 extends BaseEditor {
},
'settings list focus helper');

this.createSettingsTree(bodyContainer);

this.createSettingsTree(this.bodyContainer);
this.positionScrollbar();
this.createFocusSink(
bodyContainer,
this.bodyContainer,
e => {
if (DOM.findParentWithClass(e.relatedTarget, 'settings-editor-tree')) {
if (this.settingsTree.getScrollPosition() < 1) {
Expand All @@ -318,13 +321,21 @@ export class SettingsEditor2 extends BaseEditor {
'settings list focus helper'
);

this.createTOC(bodyContainer);
this.createTOC(this.bodyContainer);

if (this.environmentService.appQuality !== 'stable') {
this.createFeedbackButton(bodyContainer);
this.createFeedbackButton(this.bodyContainer);
}
}

private positionScrollbar(): void {
let settingsScrollbar = this.bodyContainer.querySelector('.settings-editor > .settings-body .settings-tree-container .scrollbar.vertical') as HTMLElement
console.log(settingsScrollbar)
setTimeout(() => {
settingsScrollbar.style.top = `${this.bodyContainer.offsetTop}px`;
}, 0)
}

private createFocusSink(container: HTMLElement, callback: (e: any) => boolean, label: string): HTMLElement {
const listFocusSink = DOM.append(container, $('.settings-tree-focus-sink'));
listFocusSink.setAttribute('aria-label', label);
Expand Down