提交 4eb771bf 编写于 作者: B Benjamin Pasero

notifications - tweak colors and focus

上级 068039d5
......@@ -1016,6 +1016,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
if (styles.listFocusBackground) {
content.push(`.monaco-list.${this.idPrefix}:focus .monaco-list-row.focused { background-color: ${styles.listFocusBackground}; }`);
content.push(`.monaco-list.${this.idPrefix}:focus .monaco-list-row.focused:hover { background-color: ${styles.listFocusBackground}; }`); // overwrite :hover style in this case!
}
if (styles.listFocusForeground) {
......
......@@ -62,6 +62,8 @@ export class NotificationsCenter extends Themable {
public show(): void {
if (this._isVisible) {
this.focusNotificationsList();
return; // already visible
}
......@@ -77,10 +79,25 @@ export class NotificationsCenter extends Themable {
// Show all notifications that are present now
this.onNotificationsAdded(0, this.model.notifications);
// Focus
this.focusNotificationsList();
// Event
this._onDidChangeVisibility.fire();
}
private focusNotificationsList(): void {
if (!this._isVisible) {
return;
}
this.list.domFocus();
if (this.list.getFocus().length === 0) {
this.list.focusFirst();
}
}
private createNotificationsList(): void {
// List Container
......@@ -98,12 +115,20 @@ export class NotificationsCenter extends Themable {
new NotificationsListDelegate(this.listContainer),
[renderer],
{
ariaLabel: localize('notificationsList', "Notifications List"),
multipleSelectionSupport: true
ariaLabel: localize('notificationsList', "Notifications List")
} as IListOptions<INotificationViewItem>
);
this.toUnbind.push(this.list);
// Only allow for focus in notifications, as the
// selection is too strong over the contents of
// the notification
this.toUnbind.push(this.list.onSelectionChange(e => {
if (e.indexes.length > 0) {
this.list.setSelection([]);
}
}));
this.container.appendChild(this.listContainer);
this.updateStyles();
......@@ -139,8 +164,7 @@ export class NotificationsCenter extends Themable {
private updateNotificationsList(start: number, deleteCount: number, items: INotificationViewItem[] = []) {
// Remember focus/selection
const selection = this.indexToItems(this.list.getSelection());
// Remember focus
const focus = this.indexToItems(this.list.getFocus());
// Update view model
......@@ -155,9 +179,8 @@ export class NotificationsCenter extends Themable {
this.hide();
}
// Otherwise restore focus/selection
// Otherwise restore focus
else {
this.list.setSelection(selection.map(s => this.viewModel.indexOf(s)));
this.list.setFocus(focus.map(f => this.viewModel.indexOf(f)));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册