@brandup/ui-input 1.0.44 → 1.0.45

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/source/input.ts +12 -0
package/package.json CHANGED
@@ -24,12 +24,12 @@
24
24
  "email": "it@brandup.online"
25
25
  },
26
26
  "license": "Apache-2.0",
27
- "version": "1.0.44",
27
+ "version": "1.0.45",
28
28
  "main": "source/index.ts",
29
29
  "types": "source/index.ts",
30
30
  "dependencies": {
31
- "@brandup/ui": "^2.0.7",
32
- "@brandup/ui-kit": "^1.0.44"
31
+ "@brandup/ui": "^2.0.9",
32
+ "@brandup/ui-kit": "^1.0.45"
33
33
  },
34
34
  "files": [
35
35
  "source",
package/source/input.ts CHANGED
@@ -64,6 +64,12 @@ export abstract class InputControl<T extends InputType, TEvents = {}>
64
64
  * (например, редактор с отложенной сериализацией). Вызывается перед каждым чтением значения
65
65
  * снаружи: валидация, отправка формы, сбор `FormData`. По умолчанию ничего не делает —
66
66
  * у контролов, пишущих в поле сразу, синхронизировать нечего.
67
+ *
68
+ * Native constraint validation cannot be intercepted — it runs before the `submit` event.
69
+ * Submitting by button is unaffected: the click moves focus away first, and leaving the field
70
+ * brings the value over. What remains is submitting without losing focus — {@link __requestSubmit}
71
+ * covers the Enter case, while a host-driven `form.requestSubmit()` on a focused field must
72
+ * go through it as well.
67
73
  */
68
74
  protected __syncValue(): void {}
69
75
 
@@ -120,6 +126,12 @@ export abstract class InputControl<T extends InputType, TEvents = {}>
120
126
  const form = this.form;
121
127
  if (this.readonly || this.disabled || !form) return;
122
128
 
129
+ // Constraint validation runs before the submit event, so syncing in its handler is too
130
+ // late — the browser would read the value element first. Losing focus normally brings the
131
+ // value over, but submitting by Enter happens without it, and a required field would
132
+ // refuse an empty value while the text is right there.
133
+ this.__syncValue();
134
+
123
135
  if (typeof form.requestSubmit !== "function") {
124
136
  this.__submitForm(); // движок без requestSubmit — хотя бы уведомим обработчиков
125
137
  return;