Skip to content

Commit 8dbbb19

Browse files
stevegoltonGerrit Code Review
authored andcommitted
Merge "ui: Fix omnibox state restoration bug" into main
2 parents 8f084bf + 9a31769 commit 8dbbb19

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

ui/src/core/omnibox_manager.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export enum OmniboxMode {
2121
Query,
2222
Command,
2323
Prompt,
24-
StatusMessage,
2524
}
2625

2726
interface Prompt {
@@ -101,17 +100,12 @@ export class OmniboxManagerImpl implements OmniboxManager {
101100
showStatusMessage(msg: string, durationMs = 2000) {
102101
this._statusMessage = msg;
103102
const generation = ++this._statusMessageGeneration;
104-
const prevMode = this._mode;
105-
this._mode = OmniboxMode.StatusMessage;
106103
raf.scheduleFullRedraw();
107104
if (durationMs === 0) return; // Don't auto-reset
108105
setTimeout(() => {
109106
if (this._statusMessageGeneration !== generation) return;
110107
raf.scheduleFullRedraw();
111108
this._statusMessage = '';
112-
if (this._mode === OmniboxMode.StatusMessage) {
113-
this._mode = prevMode;
114-
}
115109
}, durationMs);
116110
}
117111

@@ -160,6 +154,7 @@ export class OmniboxManagerImpl implements OmniboxManager {
160154
reset(focus = true): void {
161155
this.setMode(defaultMode, focus);
162156
this._omniboxSelectionIndex = 0;
157+
this._statusMessage = '';
163158
raf.scheduleFullRedraw();
164159
}
165160

ui/src/frontend/ui_main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,15 @@ export class UiMainPerTrace implements m.ClassComponent {
399399
}
400400

401401
private renderOmnibox(): m.Children {
402-
const omniboxMode = AppImpl.instance.omnibox.mode;
403-
if (omniboxMode === OmniboxMode.StatusMessage) {
402+
const omnibox = AppImpl.instance.omnibox;
403+
const omniboxMode = omnibox.mode;
404+
const statusMessage = omnibox.statusMessage;
405+
if (statusMessage !== '') {
404406
return m(
405407
`.omnibox.message-mode`,
406408
m(`input[readonly][disabled][ref=omnibox]`, {
407409
value: '',
408-
placeholder: AppImpl.instance.omnibox.statusMessage,
410+
placeholder: statusMessage,
409411
}),
410412
);
411413
} else if (omniboxMode === OmniboxMode.Command) {

0 commit comments

Comments
 (0)