mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
* fix search on notebooks * keep focus on findwidget
This commit is contained in:
@@ -337,15 +337,15 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _onFindInputKeyDown(e: IKeyboardEvent): void {
|
private _onFindInputKeyDown(e: IKeyboardEvent): void {
|
||||||
|
// focus on findWidget after navigating to result to prevent manually selecting the findInput to go to the next result
|
||||||
if (e.equals(KeyCode.Enter)) {
|
if (e.equals(KeyCode.Enter)) {
|
||||||
this._notebookController.getAction(ACTION_IDS.FIND_NEXT).run().then(null, onUnexpectedError);
|
this._notebookController.getAction(ACTION_IDS.FIND_NEXT).run().then(null, onUnexpectedError).finally(() => this._findInput.focus());
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// focus on findWidget after navigating to result to prevent manually selecting findInput to go to the previous result
|
||||||
if (e.equals(KeyMod.Shift | KeyCode.Enter)) {
|
if (e.equals(KeyMod.Shift | KeyCode.Enter)) {
|
||||||
this._notebookController.getAction(ACTION_IDS.FIND_PREVIOUS).run().then(null, onUnexpectedError);
|
this._notebookController.getAction(ACTION_IDS.FIND_PREVIOUS).run().then(null, onUnexpectedError).finally(() => this._findInput.focus());
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,46 +146,49 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
// For Escape - the focused element is the div.notebook-preview or textarea.inputarea of the cell, so we need to make sure that it is a descendant of the current active cell
|
// For Escape - the focused element is the div.notebook-preview or textarea.inputarea of the cell, so we need to make sure that it is a descendant of the current active cell
|
||||||
// on the current active editor.
|
// on the current active editor.
|
||||||
const activeCellElement = this.container.nativeElement.querySelector(`.editor-group-container.active .notebook-cell.active`);
|
const activeCellElement = this.container.nativeElement.querySelector(`.editor-group-container.active .notebook-cell.active`);
|
||||||
|
const findWidgetVisible = !!document.querySelector(`.editor-widget.find-widget.visible`);
|
||||||
let handled = false;
|
let handled = false;
|
||||||
if (DOM.isAncestor(this.container.nativeElement, document.activeElement) && this.isActive() && this.model.activeCell) {
|
// check that the find widget is not opened before handling notebook cell events
|
||||||
const event = new StandardKeyboardEvent(e);
|
if (!findWidgetVisible) {
|
||||||
if (!this.model.activeCell?.isEditMode) {
|
if (DOM.isAncestor(this.container.nativeElement, document.activeElement) && this.isActive() && this.model.activeCell) {
|
||||||
if (event.keyCode === KeyCode.DownArrow) {
|
const event = new StandardKeyboardEvent(e);
|
||||||
let next = (this.findCellIndex(this.model.activeCell) + 1) % this.cells.length;
|
if (!this.model.activeCell?.isEditMode) {
|
||||||
|
if (event.keyCode === KeyCode.DownArrow) {
|
||||||
|
let next = (this.findCellIndex(this.model.activeCell) + 1) % this.cells.length;
|
||||||
|
|
||||||
this.navigateToCell(this.cells[next]);
|
this.navigateToCell(this.cells[next]);
|
||||||
handled = true;
|
handled = true;
|
||||||
} else if (event.keyCode === KeyCode.UpArrow) {
|
} else if (event.keyCode === KeyCode.UpArrow) {
|
||||||
let index = this.findCellIndex(this.model.activeCell);
|
let index = this.findCellIndex(this.model.activeCell);
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
index = this.cells.length;
|
index = this.cells.length;
|
||||||
|
}
|
||||||
|
this.navigateToCell(this.cells[--index]);
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
else if (event.keyCode === KeyCode.Enter) {
|
||||||
|
this.toggleEditMode();
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
else if (event.keyCode === KeyCode.Escape) {
|
||||||
|
// unselects active cell and removes the focus from code cells
|
||||||
|
this.unselectActiveCell();
|
||||||
|
(document.activeElement as HTMLElement).blur();
|
||||||
|
handled = true;
|
||||||
}
|
}
|
||||||
this.navigateToCell(this.cells[--index]);
|
|
||||||
handled = true;
|
|
||||||
}
|
}
|
||||||
else if (event.keyCode === KeyCode.Enter) {
|
} else if (DOM.isAncestor(document.activeElement, activeCellElement) && this.isActive() && this.model.activeCell) {
|
||||||
|
const event = new StandardKeyboardEvent(e);
|
||||||
|
if (event.keyCode === KeyCode.Escape) {
|
||||||
|
// first time hitting escape removes the cursor from code cell and changes toolbar in text cells and changes edit mode to false
|
||||||
this.toggleEditMode();
|
this.toggleEditMode();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
else if (event.keyCode === KeyCode.Escape) {
|
|
||||||
// unselects active cell and removes the focus from code cells
|
|
||||||
this.unselectActiveCell();
|
|
||||||
(document.activeElement as HTMLElement).blur();
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (DOM.isAncestor(document.activeElement, activeCellElement) && this.isActive() && this.model.activeCell) {
|
if (handled) {
|
||||||
const event = new StandardKeyboardEvent(e);
|
DOM.EventHelper.stop(e);
|
||||||
if (event.keyCode === KeyCode.Escape) {
|
|
||||||
// first time hitting escape removes the cursor from code cell and changes toolbar in text cells and changes edit mode to false
|
|
||||||
this.toggleEditMode();
|
|
||||||
handled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (handled) {
|
|
||||||
DOM.EventHelper.stop(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
}));
|
||||||
this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this));
|
this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this));
|
||||||
this.updateTheme(this.themeService.getColorTheme());
|
this.updateTheme(this.themeService.getColorTheme());
|
||||||
|
|||||||
Reference in New Issue
Block a user