This commit is contained in:
Alex Dima 2021-01-28 21:26:54 +01:00
parent 29c5c52302
commit 791930308f
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0

View file

@ -147,6 +147,7 @@ export class TextAreaInput extends Disposable {
private readonly _host: ITextAreaInputHost;
private readonly _textArea: TextAreaWrapper;
private readonly _asyncTriggerCut: RunOnceScheduler;
private readonly _asyncFocusGainWriteScreenReaderContent: RunOnceScheduler;
private _textAreaState: TextAreaState;
private _selectionChangeListener: IDisposable | null;
@ -160,6 +161,7 @@ export class TextAreaInput extends Disposable {
this._host = host;
this._textArea = this._register(new TextAreaWrapper(textArea));
this._asyncTriggerCut = this._register(new RunOnceScheduler(() => this._onCut.fire(), 0));
this._asyncFocusGainWriteScreenReaderContent = this._register(new RunOnceScheduler(() => this.writeScreenReaderContent('asyncFocusGain'), 0));
this._textAreaState = TextAreaState.EMPTY;
this._selectionChangeListener = null;
@ -359,7 +361,15 @@ export class TextAreaInput extends Disposable {
}));
this._register(dom.addDisposableListener(textArea.domNode, 'focus', () => {
const hadFocus = this._hasFocus;
this._setHasFocus(true);
if (browser.isSafari && !hadFocus && this._hasFocus) {
// When "tabbing into" the textarea, immediately after dispatching the 'focus' event,
// Safari will always move the selection at offset 0 in the textarea
this._asyncFocusGainWriteScreenReaderContent.schedule();
}
}));
this._register(dom.addDisposableListener(textArea.domNode, 'blur', () => {
if (this._isDoingComposition) {