|
7 | 7 | import { Widget } from '@theia/core/shared/@phosphor/widgets';
|
8 | 8 | import { Message } from '@theia/core/shared/@phosphor/messaging';
|
9 | 9 | import { Emitter } from '@theia/core/lib/common/event';
|
| 10 | +import { Deferred } from '@theia/core/lib/common/promise-util'; |
10 | 11 | import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
|
11 | 12 | import { CommandService } from '@theia/core/lib/common/command';
|
12 | 13 | import { MessageService } from '@theia/core/lib/common/message-service';
|
@@ -42,6 +43,7 @@ export abstract class ListWidget<
|
42 | 43 | * Do not touch or use it. It is for setting the focus on the `input` after the widget activation.
|
43 | 44 | */
|
44 | 45 | protected focusNode: HTMLElement | undefined;
|
| 46 | + private readonly didReceiveFirstFocus = new Deferred(); |
45 | 47 | protected readonly searchOptionsChangeEmitter = new Emitter<
|
46 | 48 | Partial<S> | undefined
|
47 | 49 | >();
|
@@ -117,6 +119,7 @@ export abstract class ListWidget<
|
117 | 119 |
|
118 | 120 | protected onFocusResolved = (element: HTMLElement | undefined): void => {
|
119 | 121 | this.focusNode = element;
|
| 122 | + this.didReceiveFirstFocus.resolve(); |
120 | 123 | };
|
121 | 124 |
|
122 | 125 | protected async install({
|
@@ -192,7 +195,9 @@ export abstract class ListWidget<
|
192 | 195 | * If it is `undefined`, updates the view state by re-running the search with the current `filterText` term.
|
193 | 196 | */
|
194 | 197 | refresh(searchOptions: Partial<S> | undefined): void {
|
195 |
| - this.searchOptionsChangeEmitter.fire(searchOptions); |
| 198 | + this.didReceiveFirstFocus.promise.then(() => |
| 199 | + this.searchOptionsChangeEmitter.fire(searchOptions) |
| 200 | + ); |
196 | 201 | }
|
197 | 202 |
|
198 | 203 | updateScrollBar(): void {
|
|
0 commit comments