diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 6b1756b4778..236f1b83e41 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -619,6 +619,9 @@ "./vs/workbench/parts/extensions/electron-browser/extensionsUtils.ts", "./vs/workbench/parts/extensions/node/extensionsWorkbenchService.ts", "./vs/workbench/parts/extensions/test/common/extensionQuery.test.ts", + "./vs/workbench/parts/feedback/electron-browser/feedback.contribution.ts", + "./vs/workbench/parts/feedback/electron-browser/feedback.ts", + "./vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts", "./vs/workbench/parts/files/common/explorerModel.ts", "./vs/workbench/parts/files/common/files.ts", "./vs/workbench/parts/files/electron-browser/views/explorerDecorationsProvider.ts", diff --git a/src/vs/workbench/parts/feedback/electron-browser/feedback.ts b/src/vs/workbench/parts/feedback/electron-browser/feedback.ts index a6f133c193d..1c0d70f0874 100644 --- a/src/vs/workbench/parts/feedback/electron-browser/feedback.ts +++ b/src/vs/workbench/parts/feedback/electron-browser/feedback.ts @@ -47,10 +47,10 @@ export class FeedbackDropdown extends Dropdown { private readonly feedbackDelegate: IFeedbackDelegate; - private feedbackForm: HTMLFormElement; - private feedbackDescriptionInput: HTMLTextAreaElement; - private smileyInput: HTMLElement; - private frownyInput: HTMLElement; + private feedbackForm: HTMLFormElement | null; + private feedbackDescriptionInput: HTMLTextAreaElement | null; + private smileyInput: HTMLElement | null; + private frownyInput: HTMLElement | null; private sendButton: Button; private hideButton: HTMLInputElement; private remainingCharacterCount: HTMLElement; @@ -108,7 +108,7 @@ export class FeedbackDropdown extends Dropdown { dom.addClass(container, 'monaco-menu-container'); // Form - this.feedbackForm = dom.append(container, dom.$('form.feedback-form')); + this.feedbackForm = dom.append(container, dom.$('form.feedback-form')); this.feedbackForm.setAttribute('action', 'javascript:void(0);'); // Title @@ -133,7 +133,13 @@ export class FeedbackDropdown extends Dropdown { } if (darkenFactor) { - closeBtn.style.backgroundColor = darken(theme.getColor(editorWidgetBackground), darkenFactor)(theme).toString(); + const backgroundBaseColor = theme.getColor(editorWidgetBackground); + if (backgroundBaseColor) { + const backgroundColor = darken(backgroundBaseColor, darkenFactor)(theme); + if (backgroundColor) { + closeBtn.style.backgroundColor = backgroundColor.toString(); + } + } } })); @@ -242,7 +248,7 @@ export class FeedbackDropdown extends Dropdown { this.remainingCharacterCount.textContent = this.getCharCountText(0); // Feedback Input Form - this.feedbackDescriptionInput = dom.append(this.feedbackForm, dom.$('textarea.feedback-description')); + this.feedbackDescriptionInput = dom.append(this.feedbackForm, dom.$('textarea.feedback-description')); this.feedbackDescriptionInput.rows = 3; this.feedbackDescriptionInput.maxLength = this.maxFeedbackCharacters; this.feedbackDescriptionInput.textContent = this.feedback; @@ -278,9 +284,10 @@ export class FeedbackDropdown extends Dropdown { this.sendButton.onDidClick(() => this.onSubmit()); disposables.push(attachStylerCallback(this.themeService, { widgetShadow, editorWidgetBackground, inputBackground, inputForeground, inputBorder, editorBackground, contrastBorder }, colors => { - this.feedbackForm.style.backgroundColor = colors.editorWidgetBackground ? colors.editorWidgetBackground.toString() : null; - this.feedbackForm.style.boxShadow = colors.widgetShadow ? `0 0 8px ${colors.widgetShadow}` : null; - + if (this.feedbackForm) { + this.feedbackForm.style.backgroundColor = colors.editorWidgetBackground ? colors.editorWidgetBackground.toString() : null; + this.feedbackForm.style.boxShadow = colors.widgetShadow ? `0 0 8px ${colors.widgetShadow}` : null; + } if (this.feedbackDescriptionInput) { this.feedbackDescriptionInput.style.backgroundColor = colors.inputBackground ? colors.inputBackground.toString() : null; this.feedbackDescriptionInput.style.color = colors.inputForeground ? colors.inputForeground.toString() : null; @@ -313,27 +320,39 @@ export class FeedbackDropdown extends Dropdown { } private updateCharCountText(): void { - this.remainingCharacterCount.innerText = this.getCharCountText(this.feedbackDescriptionInput.value.length); - this.sendButton.enabled = this.feedbackDescriptionInput.value.length > 0; + if (this.feedbackDescriptionInput) { + this.remainingCharacterCount.innerText = this.getCharCountText(this.feedbackDescriptionInput.value.length); + this.sendButton.enabled = this.feedbackDescriptionInput.value.length > 0; + } } private setSentiment(smile: boolean): void { if (smile) { - dom.addClass(this.smileyInput, 'checked'); - this.smileyInput.setAttribute('aria-checked', 'true'); - dom.removeClass(this.frownyInput, 'checked'); - this.frownyInput.setAttribute('aria-checked', 'false'); + if (this.smileyInput) { + dom.addClass(this.smileyInput, 'checked'); + this.smileyInput.setAttribute('aria-checked', 'true'); + } + if (this.frownyInput) { + dom.removeClass(this.frownyInput, 'checked'); + this.frownyInput.setAttribute('aria-checked', 'false'); + } } else { - dom.addClass(this.frownyInput, 'checked'); - this.frownyInput.setAttribute('aria-checked', 'true'); - dom.removeClass(this.smileyInput, 'checked'); - this.smileyInput.setAttribute('aria-checked', 'false'); + if (this.frownyInput) { + dom.addClass(this.frownyInput, 'checked'); + this.frownyInput.setAttribute('aria-checked', 'true'); + } + if (this.smileyInput) { + dom.removeClass(this.smileyInput, 'checked'); + this.smileyInput.setAttribute('aria-checked', 'false'); + } } this.sentiment = smile ? 1 : 0; this.maxFeedbackCharacters = this.feedbackDelegate.getCharacterLimit(this.sentiment); this.updateCharCountText(); - this.feedbackDescriptionInput.maxLength = this.maxFeedbackCharacters; + if (this.feedbackDescriptionInput) { + this.feedbackDescriptionInput.maxLength = this.maxFeedbackCharacters; + } } private invoke(element: HTMLElement, disposables: IDisposable[], callback: () => void): HTMLElement { @@ -392,7 +411,7 @@ export class FeedbackDropdown extends Dropdown { } private onSubmit(): void { - if ((this.feedbackForm.checkValidity && !this.feedbackForm.checkValidity())) { + if (!this.feedbackForm || !this.feedbackDescriptionInput || (this.feedbackForm.checkValidity && !this.feedbackForm.checkValidity())) { return; } diff --git a/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts b/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts index 67e4b743813..09be3a9f93f 100644 --- a/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts +++ b/src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle'; import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar'; import { FeedbackDropdown, IFeedback, IFeedbackDelegate, FEEDBACK_VISIBLE_CONFIG, IFeedbackDropdownOptions } from 'vs/workbench/parts/feedback/electron-browser/feedback'; import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView'; @@ -52,7 +52,7 @@ class TwitterFeedbackService implements IFeedbackDelegate { } export class FeedbackStatusbarItem extends Themable implements IStatusbarItem { - private dropdown: FeedbackDropdown; + private dropdown: FeedbackDropdown | undefined; private enabled: boolean; private container: HTMLElement; private hideAction: HideAction; @@ -89,7 +89,7 @@ export class FeedbackStatusbarItem extends Themable implements IStatusbarItem { protected updateStyles(): void { super.updateStyles(); - if (this.dropdown) { + if (this.dropdown && this.dropdown.label) { this.dropdown.label.style.backgroundColor = (this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND)); } } @@ -148,7 +148,7 @@ export class FeedbackStatusbarItem extends Themable implements IStatusbarItem { clearNode(this.container); } - return null; + return Disposable.None; } }