Skip to content

Commit 866cdb5

Browse files
committed
Fixes clipped graph search messages
1 parent 8c15627 commit 866cdb5

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/webviews/apps/shared/components/search/search-box.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { TemplateResult } from 'lit';
22
import { css, html } from 'lit';
3-
import { customElement, property, query } from 'lit/decorators.js';
3+
import { customElement, property, query, state } from 'lit/decorators.js';
44
import type { Disposable } from 'vscode';
55
import { isMac } from '@env/platform';
66
import type { SearchQuery } from '../../../../../constants.search';
@@ -113,8 +113,15 @@ export class GlSearchBox extends GlElement {
113113
@property({ type: String })
114114
errorMessage = '';
115115

116+
@state() _value!: string;
116117
@property({ type: String })
117-
value = '';
118+
get value() {
119+
return this._value;
120+
}
121+
set value(value: string) {
122+
if (this._value !== undefined) return;
123+
this._value = value;
124+
}
118125

119126
@property({ type: Boolean })
120127
matchAll = false;
@@ -185,6 +192,10 @@ export class GlSearchBox extends GlElement {
185192
this.searchInput?.logSearch(query);
186193
}
187194

195+
setSearchQuery(query: string): void {
196+
this._value = query;
197+
}
198+
188199
private handleShortcutKeys(e: KeyboardEvent) {
189200
if (e.altKey) return;
190201

@@ -267,7 +278,7 @@ export class GlSearchBox extends GlElement {
267278
.matchAll="${this.matchAll}"
268279
.matchCase="${this.matchCase}"
269280
.matchRegex="${this.matchRegex}"
270-
.value="${this.value}"
281+
.value="${this._value ?? ''}"
271282
@gl-search-navigate="${(e: CustomEvent<SearchNavigationEventDetail>) => {
272283
e.stopImmediatePropagation();
273284
this.navigate(e.detail.direction);
@@ -309,6 +320,6 @@ export class GlSearchBox extends GlElement {
309320
</button>
310321
</gl-tooltip>
311322
</div>
312-
<progress-indicator active="${this.searching}"></progress-indicator>`;
323+
<progress-indicator ?active="${this.searching}"></progress-indicator>`;
313324
}
314325
}

src/webviews/apps/shared/components/search/search-input.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,16 @@ export class GlSearchInput extends GlElement {
234234
return `${this.label} commits (↑↓ for history), e.g. "Updates dependencies" author:eamodio`;
235235
}
236236

237-
@property({ type: String }) value = '';
237+
@state() _value!: string;
238+
@property({ type: String })
239+
get value() {
240+
return this._value;
241+
}
242+
set value(value: string) {
243+
if (this._value !== undefined) return;
244+
this._value = value;
245+
}
246+
238247
@property({ type: Boolean }) filter = false;
239248
@property({ type: Boolean }) matchAll = false;
240249
@property({ type: Boolean }) matchCase = false;
@@ -254,7 +263,7 @@ export class GlSearchInput extends GlElement {
254263

255264
private handleClear(_e: Event) {
256265
this.focus();
257-
this.value = '';
266+
this._value = '';
258267
this.debouncedOnSearchChanged();
259268
}
260269

@@ -294,7 +303,7 @@ export class GlSearchInput extends GlElement {
294303

295304
private handleInput(e: InputEvent) {
296305
const value = (e.target as HTMLInputElement)?.value;
297-
this.value = value;
306+
this._value = value;
298307
this.updateHelpText();
299308
this.debouncedOnSearchChanged();
300309
}
@@ -390,6 +399,10 @@ export class GlSearchInput extends GlElement {
390399
this.searchHistoryPos = this.searchHistory.length - 1;
391400
}
392401

402+
setSearchQuery(query: string): void {
403+
this._value = query;
404+
}
405+
393406
override render(): unknown {
394407
return html`<div class="field">
395408
<div class="controls controls__start">
@@ -496,7 +509,7 @@ export class GlSearchInput extends GlElement {
496509
type="text"
497510
spellcheck="false"
498511
placeholder="${this.placeholder}"
499-
.value="${this.value}"
512+
.value="${this._value ?? ''}"
500513
aria-valid="${!this.errorMessage}"
501514
aria-describedby="${this.errorMessage !== '' || this.helpType != null ? 'help-text' : ''}"
502515
@input="${this.handleInput}"

0 commit comments

Comments
 (0)