mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Add option to override 'pinned' when setting list selection
Fix #114651
This commit is contained in:
@@ -429,12 +429,14 @@ export interface IResourceNavigatorOptions {
|
||||
|
||||
export interface SelectionKeyboardEvent extends KeyboardEvent {
|
||||
preserveFocus?: boolean;
|
||||
pinned?: boolean;
|
||||
__forceEvent?: boolean;
|
||||
}
|
||||
|
||||
export function getSelectionKeyboardEvent(typeArg = 'keydown', preserveFocus?: boolean): SelectionKeyboardEvent {
|
||||
export function getSelectionKeyboardEvent(typeArg = 'keydown', preserveFocus?: boolean, pinned?: boolean): SelectionKeyboardEvent {
|
||||
const e = new KeyboardEvent(typeArg);
|
||||
(<SelectionKeyboardEvent>e).preserveFocus = preserveFocus;
|
||||
(<SelectionKeyboardEvent>e).pinned = pinned;
|
||||
(<SelectionKeyboardEvent>e).__forceEvent = true;
|
||||
|
||||
return e;
|
||||
@@ -478,8 +480,9 @@ abstract class ResourceNavigator<T> extends Disposable {
|
||||
const focus = this.widget.getFocus();
|
||||
this.widget.setSelection(focus, event.browserEvent);
|
||||
|
||||
const preserveFocus = typeof (event.browserEvent as SelectionKeyboardEvent).preserveFocus === 'boolean' ? (event.browserEvent as SelectionKeyboardEvent).preserveFocus! : true;
|
||||
const pinned = !preserveFocus;
|
||||
const selectionKeyboardEvent = event.browserEvent as SelectionKeyboardEvent;
|
||||
const preserveFocus = typeof selectionKeyboardEvent.preserveFocus === 'boolean' ? selectionKeyboardEvent.preserveFocus! : true;
|
||||
const pinned = typeof selectionKeyboardEvent.pinned === 'boolean' ? selectionKeyboardEvent.pinned! : !preserveFocus;
|
||||
const sideBySide = false;
|
||||
|
||||
this._open(this.getSelectedElement(), preserveFocus, pinned, sideBySide, event.browserEvent);
|
||||
@@ -490,8 +493,9 @@ abstract class ResourceNavigator<T> extends Disposable {
|
||||
return;
|
||||
}
|
||||
|
||||
const preserveFocus = typeof (event.browserEvent as SelectionKeyboardEvent).preserveFocus === 'boolean' ? (event.browserEvent as SelectionKeyboardEvent).preserveFocus! : true;
|
||||
const pinned = !preserveFocus;
|
||||
const selectionKeyboardEvent = event.browserEvent as SelectionKeyboardEvent;
|
||||
const preserveFocus = typeof selectionKeyboardEvent.preserveFocus === 'boolean' ? selectionKeyboardEvent.preserveFocus! : true;
|
||||
const pinned = typeof selectionKeyboardEvent.pinned === 'boolean' ? selectionKeyboardEvent.pinned! : !preserveFocus;
|
||||
const sideBySide = false;
|
||||
|
||||
this._open(this.getSelectedElement(), preserveFocus, pinned, sideBySide, event.browserEvent);
|
||||
|
||||
@@ -825,7 +825,7 @@ export class SearchView extends ViewPane {
|
||||
if (next === selected) {
|
||||
this.tree.setFocus([]);
|
||||
}
|
||||
this.tree.setFocus([next], getSelectionKeyboardEvent(undefined, false));
|
||||
this.tree.setFocus([next], getSelectionKeyboardEvent(undefined, false, false));
|
||||
this.tree.reveal(next);
|
||||
const ariaLabel = this.treeAccessibilityProvider.getAriaLabel(next);
|
||||
if (ariaLabel) { aria.alert(ariaLabel); }
|
||||
@@ -866,7 +866,7 @@ export class SearchView extends ViewPane {
|
||||
if (prev === selected) {
|
||||
this.tree.setFocus([]);
|
||||
}
|
||||
this.tree.setFocus([prev], getSelectionKeyboardEvent(undefined, false));
|
||||
this.tree.setFocus([prev], getSelectionKeyboardEvent(undefined, false, false));
|
||||
this.tree.reveal(prev);
|
||||
const ariaLabel = this.treeAccessibilityProvider.getAriaLabel(prev);
|
||||
if (ariaLabel) { aria.alert(ariaLabel); }
|
||||
|
||||
Reference in New Issue
Block a user