Skip to content

Commit 762afec

Browse files
committed
invalid submit attribute
1 parent 6d17bc0 commit 762afec

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/uui-base/lib/mixins/FormControlMixin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ export const FormControlMixin = <T extends Constructor<LitElement>>(
222222
this._removeFormListeners();
223223
this._form = this._internals.form;
224224
if (this._form) {
225+
if (this._form.hasAttribute('invalid-submit')) {
226+
this.pristine = false;
227+
}
225228
this._form.addEventListener('submit', this._onFormSubmit);
226229
}
227230
}

packages/uui-input/lib/uui-input-form-example.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ export class UUIInputInFormExampleElement extends LitElement {
4444

4545
const isValid = this._form.checkValidity();
4646
if (!isValid) {
47+
this._form.setAttribute('invalid-submit', '');
4748
return;
4849
}
4950

51+
this._form.removeAttribute('invalid-submit');
52+
5053
const formData = new FormData(this._form);
5154

5255
for (const value of formData.values()) {

0 commit comments

Comments
 (0)