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

Cannot read properties of undefined (reading 'layout') #213797

Merged
merged 1 commit into from
May 29, 2024
Merged
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
22 changes: 11 additions & 11 deletions src/vs/workbench/contrib/remote/browser/tunnelView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ export class TunnelPanel extends ViewPane {
static readonly TITLE: ILocalizedString = nls.localize2('remote.tunnel', "Ports");

private panelContainer: HTMLElement | undefined;
private table!: WorkbenchTable<ITunnelItem>;
private table: WorkbenchTable<ITunnelItem> | undefined;
private readonly tableDisposables: DisposableStore = this._register(new DisposableStore());
private tunnelTypeContext: IContextKey<TunnelType>;
private tunnelCloseableContext: IContextKey<boolean>;
Expand Down Expand Up @@ -830,7 +830,7 @@ export class TunnelPanel extends ViewPane {
updateActions();
this.registerPrivacyActions();
this.createTable();
this.table.layout(this.height, this.width);
this.table?.layout(this.height, this.width);
}
}));
}
Expand Down Expand Up @@ -913,7 +913,7 @@ export class TunnelPanel extends ViewPane {
this.tableDisposables.add(this.table.onDidFocus(() => this.tunnelViewFocusContext.set(true)));
this.tableDisposables.add(this.table.onDidBlur(() => this.tunnelViewFocusContext.set(false)));

const rerender = () => this.table.splice(0, Number.POSITIVE_INFINITY, this.viewModel.all);
const rerender = () => this.table?.splice(0, Number.POSITIVE_INFINITY, this.viewModel.all);

rerender();
let lastPortCount = this.portCount;
Expand All @@ -927,7 +927,7 @@ export class TunnelPanel extends ViewPane {
}));

this.tableDisposables.add(this.table.onMouseClick(e => {
if (this.hasOpenLinkModifier(e.browserEvent)) {
if (this.hasOpenLinkModifier(e.browserEvent) && this.table) {
const selection = this.table.getSelectedElements();
if ((selection.length === 0) ||
((selection.length === 1) && (selection[0] === e.element))) {
Expand Down Expand Up @@ -959,11 +959,11 @@ export class TunnelPanel extends ViewPane {
widgetContainer.classList.add('highlight');
if (!e) {
// When we are in editing mode for a new forward, rather than updating an existing one we need to reveal the input box since it might be out of view.
this.table.reveal(this.table.indexOf(this.viewModel.input));
this.table?.reveal(this.table.indexOf(this.viewModel.input));
}
} else {
if (e && (e.tunnel.tunnelType !== TunnelType.Add)) {
this.table.setFocus(this.lastFocus);
this.table?.setFocus(this.lastFocus);
}
this.focus();
}
Expand All @@ -983,7 +983,7 @@ export class TunnelPanel extends ViewPane {

override focus(): void {
super.focus();
this.table.domFocus();
this.table?.domFocus();
}

private onFocusChanged(event: ITableEvent<ITunnelItem>) {
Expand Down Expand Up @@ -1045,7 +1045,7 @@ export class TunnelPanel extends ViewPane {
const node: TunnelItem | undefined = event.element;

if (node) {
this.table.setFocus([this.table.indexOf(node)]);
this.table?.setFocus([this.table.indexOf(node)]);
this.tunnelTypeContext.set(node.tunnelType);
this.tunnelCloseableContext.set(!!node.closeable);
this.tunnelPrivacyContext.set(node.privacy.id);
Expand All @@ -1062,7 +1062,7 @@ export class TunnelPanel extends ViewPane {
this.contextMenuService.showContextMenu({
menuId: MenuId.TunnelContext,
menuActionOptions: { shouldForwardArgs: true },
contextKeyService: this.table.contextKeyService,
contextKeyService: this.table?.contextKeyService,
getAnchor: () => event.anchor,
getActionViewItem: (action) => {
const keybinding = this.keybindingService.lookupKeybinding(action.id);
Expand All @@ -1073,7 +1073,7 @@ export class TunnelPanel extends ViewPane {
},
onHide: (wasCancelled?: boolean) => {
if (wasCancelled) {
this.table.domFocus();
this.table?.domFocus();
}
},
getActionsContext: () => node?.strip(),
Expand All @@ -1093,7 +1093,7 @@ export class TunnelPanel extends ViewPane {
this.height = height;
this.width = width;
super.layoutBody(height, width);
this.table.layout(height, width);
this.table?.layout(height, width);
}
}

Expand Down
Loading