diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 2c5fb70f56..a14ec5d54f 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -817,6 +817,13 @@ declare module 'azdata' { Informational = 'Informational' } + export interface InputBoxProperties { + /** + * The maximum number of characters allowed in the input box. + */ + maxLength?: number; + } + export namespace workspace { /** * Creates and enters a workspace at the specified location diff --git a/src/sql/base/browser/ui/inputBox/inputBox.ts b/src/sql/base/browser/ui/inputBox/inputBox.ts index 421fec5b5a..b55341f8d3 100644 --- a/src/sql/base/browser/ui/inputBox/inputBox.ts +++ b/src/sql/base/browser/ui/inputBox/inputBox.ts @@ -93,6 +93,16 @@ export class InputBox extends vsInputBox { public setHeight(value: string) { if (this._isTextAreaInput) { this.inputElement.style.height = value; + this.inputElement.style.whiteSpace = 'normal'; + } + } + + public setMaxLength(value: number | undefined) { + if (value === undefined) { + this.inputElement.removeAttribute('maxLength'); + } + else { + this.inputElement.maxLength = value; } } diff --git a/src/sql/workbench/api/common/extHostModelView.ts b/src/sql/workbench/api/common/extHostModelView.ts index ec3ec957e6..9791c0921d 100644 --- a/src/sql/workbench/api/common/extHostModelView.ts +++ b/src/sql/workbench/api/common/extHostModelView.ts @@ -1074,6 +1074,14 @@ class InputBoxWrapper extends ComponentWrapper implements azdata.InputBoxCompone this.setProperty('validationErrorMessage', v); } + public get maxLength(): number | undefined { + return this.properties['maxLength']; + } + + public set maxLength(v: number | undefined) { + this.setProperty('maxLength', v); + } + public get onTextChanged(): vscode.Event { let emitter = this._emitterMap.get(ComponentEventType.onDidChange); return emitter && emitter.event; diff --git a/src/sql/workbench/browser/modelComponents/inputbox.component.ts b/src/sql/workbench/browser/modelComponents/inputbox.component.ts index 166f5dfb67..0b2fd19646 100644 --- a/src/sql/workbench/browser/modelComponents/inputbox.component.ts +++ b/src/sql/workbench/browser/modelComponents/inputbox.component.ts @@ -222,6 +222,7 @@ export default class InputBoxComponent extends ComponentBase((props, value) => props.stopEnterPropagation = value, newValue); } + public get maxLength(): number | undefined { + return this.getPropertyOrDefault((props) => props.maxLength, undefined); + } + public focus(): void { this.inputElement.focus(); }