mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 03:28:33 -05:00
handle edit and save race condition (#20462)
* handle edit and save race condition * handle more race condition scenarios * fix error
This commit is contained in:
@@ -51,6 +51,8 @@ import { RowMoveManager, RowMoveOnDragEventData } from 'sql/base/browser/ui/tabl
|
||||
import { ITaskbarContent, Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
import { RowSelectionModel } from 'sql/base/browser/ui/table/plugins/rowSelectionModel.plugin';
|
||||
import { listFocusAndSelectionBackground } from 'sql/platform/theme/common/colors';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
export interface IDesignerStyle {
|
||||
tabbedPanelStyles?: ITabbedPanelStyles;
|
||||
@@ -282,6 +284,9 @@ export class Designer extends Disposable implements IThemable {
|
||||
|
||||
|
||||
public setInput(input: DesignerComponentInput): void {
|
||||
if (this._input) {
|
||||
void this.submitPendingChanges().catch(onUnexpectedError);
|
||||
}
|
||||
this.saveUIState();
|
||||
if (this._loadingTimeoutHandle) {
|
||||
this.stopLoading();
|
||||
@@ -303,7 +308,9 @@ export class Designer extends Disposable implements IThemable {
|
||||
this._inputDisposable.add(this._input.onRefreshRequested(() => {
|
||||
this.refresh();
|
||||
}));
|
||||
|
||||
this._inputDisposable.add(this._input.onSubmitPendingEditRequested(async () => {
|
||||
await this.submitPendingChanges();
|
||||
}));
|
||||
if (this._input.view === undefined) {
|
||||
this._input.initialize();
|
||||
} else {
|
||||
@@ -319,6 +326,14 @@ export class Designer extends Disposable implements IThemable {
|
||||
this._inputDisposable?.dispose();
|
||||
}
|
||||
|
||||
public async submitPendingChanges(): Promise<void> {
|
||||
if (this._container.contains(document.activeElement) && document.activeElement instanceof HTMLInputElement) {
|
||||
// Force the elements to fire the blur event to submit the pending changes.
|
||||
document.activeElement.blur();
|
||||
return timeout(10);
|
||||
}
|
||||
}
|
||||
|
||||
private clearUI(): void {
|
||||
this._componentMap.forEach(item => item.component.dispose());
|
||||
this._componentMap.clear();
|
||||
|
||||
Reference in New Issue
Block a user