@fluid-topics/ft-text-field 2.2.25 → 2.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,8 @@ export declare class FtTextField extends FtTextField_base implements FtTextField
44
44
  suggestionsContainer?: HTMLElement;
45
45
  providedSuggestionsInDom: FtTextFieldSuggestion[];
46
46
  slottedSuggestions: FtTextFieldSuggestion[];
47
+ private showSuggestionsOnFocus;
48
+ focusWithoutSuggestions(): void;
47
49
  focus(): void;
48
50
  blur(): void;
49
51
  protected render(): import("lit").TemplateResult<1>;
@@ -35,9 +35,10 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
35
35
  this.focused = false;
36
36
  this.inputValid = true;
37
37
  this.hidePassword = true;
38
- this.hideSuggestions = false;
38
+ this.hideSuggestions = true;
39
39
  this.visibleSuggestions = [];
40
40
  this.providedSuggestions = [];
41
+ this.showSuggestionsOnFocus = true;
41
42
  }
42
43
  /*
43
44
  * We prevent lit from creating setter and getter to differentiate
@@ -59,6 +60,11 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
59
60
  this.setFormValue(this._value);
60
61
  this.requestUpdate("value", oldValue);
61
62
  }
63
+ focusWithoutSuggestions() {
64
+ this.showSuggestionsOnFocus = false;
65
+ this.focus();
66
+ this.showSuggestionsOnFocus = true;
67
+ }
62
68
  focus() {
63
69
  var _a;
64
70
  (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
@@ -207,10 +213,10 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
207
213
  || props.has("suggestionsProvider")) {
208
214
  this.updateSuggestions();
209
215
  }
210
- if (props.has("value") && props.get("value") != null) {
216
+ if (props.has("value") && this.value) {
211
217
  this.hideSuggestions = false;
212
218
  }
213
- if (props.has("dispatchedValue") && props.get("dispatchedValue") != null) {
219
+ if (props.has("dispatchedValue")) {
214
220
  this.hideSuggestions = true;
215
221
  }
216
222
  }
@@ -243,13 +249,9 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
243
249
  if (this.newValueSuggestion) {
244
250
  this.visibleSuggestions = [...this.visibleSuggestions, this.newValueSuggestion];
245
251
  }
246
- this.hideSuggestions = this.visibleSuggestions.length <= 0;
247
252
  }
248
253
  contentAvailableCallback(props) {
249
254
  super.contentAvailableCallback(props);
250
- if (props.has("focused") && !this.hideSuggestions && this.visibleSuggestions.length > 0) {
251
- this.setSuggestionPosition();
252
- }
253
255
  if (props.has("providedSuggestions") && this.suggestionsProvider) {
254
256
  this.visibleSuggestions = [...this.providedSuggestionsInDom];
255
257
  }
@@ -336,10 +338,9 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
336
338
  }
337
339
  }
338
340
  onSuggestionSelected(event) {
339
- var _a;
340
341
  this.setValue(event.detail, true);
341
- (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
342
- setTimeout(() => this.hideSuggestions = true, 0);
342
+ this.focusWithoutSuggestions();
343
+ this.hideSuggestions = true;
343
344
  }
344
345
  onSuggestionRemoved() {
345
346
  // update suggestions after all handlers processed the event
@@ -347,7 +348,9 @@ export class FtTextField extends toFtFormComponent(FtLitElement) {
347
348
  }
348
349
  onFocus() {
349
350
  this.focused = true;
350
- this.hideSuggestions = false;
351
+ if (this.showSuggestionsOnFocus) {
352
+ this.hideSuggestions = false;
353
+ }
351
354
  }
352
355
  onMainPanelBlur() {
353
356
  var _a, _b;