Skip to content

Commit

Permalink
fix(editors): make sure editor element exist before focusing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghislain Beaulac authored and Ghislain Beaulac committed Nov 25, 2020
1 parent 3c05938 commit e57235b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/common/src/editors/autoCompleteEditor.ts
Expand Up @@ -198,7 +198,9 @@ export class AutoCompleteEditor implements Editor {
}

focus() {
this._$editorElm?.focus().select();
if (this._$editorElm) {
this._$editorElm.focus().select();
}
}

show() {
Expand Down
4 changes: 3 additions & 1 deletion packages/common/src/editors/dateEditor.ts
Expand Up @@ -216,7 +216,9 @@ export class DateEditor implements Editor {
}

focus() {
this._$input.focus();
if (this._$input) {
this._$input.focus();
}
if (this._$inputWithData && typeof this._$inputWithData.focus === 'function') {
this._$inputWithData.focus().select();
}
Expand Down
4 changes: 3 additions & 1 deletion packages/common/src/editors/longTextEditor.ts
Expand Up @@ -198,7 +198,9 @@ export class LongTextEditor implements Editor {
}

focus() {
this._$textarea.focus().select();
if (this._$textarea) {
this._$textarea.focus().select();
}
}

getValue(): string {
Expand Down
4 changes: 3 additions & 1 deletion packages/common/src/editors/sliderEditor.ts
Expand Up @@ -152,7 +152,9 @@ export class SliderEditor implements Editor {
}

focus() {
this._$input.focus();
if (this._$input) {
this._$input.focus();
}
}

show() {
Expand Down

0 comments on commit e57235b

Please sign in to comment.