提交 1584277c 编写于 作者: B Benjamin Pasero

notifications - preserve relative top

上级 1c9f266d
......@@ -107,10 +107,15 @@ export class NotificationsList extends Themable {
public updateNotificationsList(start: number, deleteCount: number, items: INotificationViewItem[] = []) {
const listHasDOMFocus = isAncestor(document.activeElement, this.listContainer);
// Remember focus
// Remember focus and relative top of that item
const focusedIndex = this.list.getFocus()[0];
const focusedItem = this.viewModel[focusedIndex];
let focusRelativeTop: number;
if (typeof focusedIndex === 'number') {
focusRelativeTop = this.list.getRelativeTop(focusedIndex);
}
// Update view model
this.viewModel.splice(start, deleteCount, ...items);
......@@ -138,6 +143,10 @@ export class NotificationsList extends Themable {
}
this.list.setFocus([indexToFocus]);
if (typeof focusRelativeTop === 'number') {
this.list.reveal(indexToFocus, focusRelativeTop);
}
}
// Restore DOM focus if we had focus before
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册