Skip to content

Commit 4eb771b

Browse files
author
Benjamin Pasero
committed
notifications - tweak colors and focus
1 parent 068039d commit 4eb771b

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/vs/base/browser/ui/list/listWidget.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
10161016

10171017
if (styles.listFocusBackground) {
10181018
content.push(`.monaco-list.${this.idPrefix}:focus .monaco-list-row.focused { background-color: ${styles.listFocusBackground}; }`);
1019+
content.push(`.monaco-list.${this.idPrefix}:focus .monaco-list-row.focused:hover { background-color: ${styles.listFocusBackground}; }`); // overwrite :hover style in this case!
10191020
}
10201021

10211022
if (styles.listFocusForeground) {

src/vs/workbench/browser/parts/notifications/notificationsCenter.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export class NotificationsCenter extends Themable {
6262

6363
public show(): void {
6464
if (this._isVisible) {
65+
this.focusNotificationsList();
66+
6567
return; // already visible
6668
}
6769

@@ -77,10 +79,25 @@ export class NotificationsCenter extends Themable {
7779
// Show all notifications that are present now
7880
this.onNotificationsAdded(0, this.model.notifications);
7981

82+
// Focus
83+
this.focusNotificationsList();
84+
8085
// Event
8186
this._onDidChangeVisibility.fire();
8287
}
8388

89+
private focusNotificationsList(): void {
90+
if (!this._isVisible) {
91+
return;
92+
}
93+
94+
this.list.domFocus();
95+
96+
if (this.list.getFocus().length === 0) {
97+
this.list.focusFirst();
98+
}
99+
}
100+
84101
private createNotificationsList(): void {
85102

86103
// List Container
@@ -98,12 +115,20 @@ export class NotificationsCenter extends Themable {
98115
new NotificationsListDelegate(this.listContainer),
99116
[renderer],
100117
{
101-
ariaLabel: localize('notificationsList', "Notifications List"),
102-
multipleSelectionSupport: true
118+
ariaLabel: localize('notificationsList', "Notifications List")
103119
} as IListOptions<INotificationViewItem>
104120
);
105121
this.toUnbind.push(this.list);
106122

123+
// Only allow for focus in notifications, as the
124+
// selection is too strong over the contents of
125+
// the notification
126+
this.toUnbind.push(this.list.onSelectionChange(e => {
127+
if (e.indexes.length > 0) {
128+
this.list.setSelection([]);
129+
}
130+
}));
131+
107132
this.container.appendChild(this.listContainer);
108133

109134
this.updateStyles();
@@ -139,8 +164,7 @@ export class NotificationsCenter extends Themable {
139164

140165
private updateNotificationsList(start: number, deleteCount: number, items: INotificationViewItem[] = []) {
141166

142-
// Remember focus/selection
143-
const selection = this.indexToItems(this.list.getSelection());
167+
// Remember focus
144168
const focus = this.indexToItems(this.list.getFocus());
145169

146170
// Update view model
@@ -155,9 +179,8 @@ export class NotificationsCenter extends Themable {
155179
this.hide();
156180
}
157181

158-
// Otherwise restore focus/selection
182+
// Otherwise restore focus
159183
else {
160-
this.list.setSelection(selection.map(s => this.viewModel.indexOf(s)));
161184
this.list.setFocus(focus.map(f => this.viewModel.indexOf(f)));
162185
}
163186
}

0 commit comments

Comments
 (0)