Reset native elements if reset() is called.

This commit is contained in:
trading_peter 2023-09-03 22:26:19 +02:00
parent 7ca87b7bdd
commit a821354288
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@tp/tp-form",
"version": "1.0.1",
"version": "1.1.0",
"description": "",
"main": "tp-form.js",
"scripts": {

View File

@ -168,7 +168,7 @@ class TpForm extends LitElement {
// Also go through the form's native elements.
for (let i = 0, li = this._nativeElements.length; i < li; i++) {
const el = this._nativeElements[i];
// Skip native controls that are wrapped by custom elements already registerd (e.g. <era-input><input></era-input>)
// Skip native controls that are wrapped by custom elements already registered (e.g. <tp-input><input></tp-input>)
if (!this._useValue(el) ||
(this._isWrapped(el) && json[el.name])) {
continue;
@ -255,6 +255,17 @@ class TpForm extends LitElement {
item.control.reset();
}
}
// Also go through the form's native elements.
for (let i = 0, li = this._nativeElements.length; i < li; i++) {
const el = this._nativeElements[i];
// Skip native controls that are wrapped by custom elements already registered (e.g. <tp-input><input></tp-input>)
if (this._isWrapped(el)) {
continue;
}
el.value = '';
}
}
focusFirstControl() {