mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-25 18:46:06 +01:00
Fix issue with CommentThread focus stealing (#196088)
Writing `vscode.CommentThread.comments` steals focus from Reply input / resets empty Reply input Fixes #182060
This commit is contained in:
@@ -156,7 +156,7 @@ export class CommentThreadBody<T extends IRange | ICellRange = IRange> extends D
|
||||
return;
|
||||
}
|
||||
|
||||
updateCommentThread(commentThread: languages.CommentThread<T>) {
|
||||
updateCommentThread(commentThread: languages.CommentThread<T>, preserveFocus: boolean) {
|
||||
const oldCommentsLen = this._commentElements.length;
|
||||
const newCommentsLen = commentThread.comments ? commentThread.comments.length : 0;
|
||||
|
||||
@@ -222,7 +222,9 @@ export class CommentThreadBody<T extends IRange | ICellRange = IRange> extends D
|
||||
}
|
||||
|
||||
this._updateAriaLabel();
|
||||
this._setFocusedComment(this._focusedComment);
|
||||
if (!preserveFocus) {
|
||||
this._setFocusedComment(this._focusedComment);
|
||||
}
|
||||
}
|
||||
|
||||
private _updateAriaLabel() {
|
||||
|
||||
@@ -213,7 +213,7 @@ export class CommentThreadWidget<T extends IRange | ICellRange = IRange> extends
|
||||
this._commentThreadDisposables = [];
|
||||
this._bindCommentThreadListeners();
|
||||
|
||||
this._body.updateCommentThread(commentThread);
|
||||
this._body.updateCommentThread(commentThread, this._commentReply?.isCommentEditorFocused() ?? false);
|
||||
this._threadIsEmpty.set(!this._body.length);
|
||||
this._header.updateCommentThread(commentThread);
|
||||
this._commentReply?.updateCommentThread(commentThread);
|
||||
|
||||
@@ -327,13 +327,9 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldMoveWidget && this._isExpanded) {
|
||||
if ((shouldMoveWidget && this._isExpanded) || (this._commentThread.collapsibleState === languages.CommentThreadCollapsibleState.Expanded && !this._isExpanded)) {
|
||||
this.show(this.arrowPosition(this._commentThread.range), 2);
|
||||
}
|
||||
|
||||
if (this._commentThread.collapsibleState === languages.CommentThreadCollapsibleState.Expanded) {
|
||||
this.show(this.arrowPosition(this._commentThread.range), 2);
|
||||
} else {
|
||||
} else if (this._commentThread.collapsibleState !== languages.CommentThreadCollapsibleState.Expanded) {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user