@marianmeres/stuic 3.76.1 → 3.76.2

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.
@@ -55,6 +55,18 @@ export function onSubmitValidityCheck(node) {
55
55
  // input (last radio input), which is not desired
56
56
  if (el.type === "radio")
57
57
  continue;
58
+ // Clear any stale `customError` flag from a prior submit attempt before
59
+ // re-dispatching the validate listeners. Without this, if the field's
60
+ // per-field validate $effect was torn down/re-mounted in a way that
61
+ // skipped re-running its `customValidator` (e.g., the parent re-rendered
62
+ // for an unrelated reason between submits), the previous submit's
63
+ // customValidity message lingers on the DOM element. Then `el.validity.valid`
64
+ // would return false here even though the customValidator now reports no
65
+ // error, silently routing the form to `submit_invalid` and never calling
66
+ // the consumer's onSubmit. The dispatched change event below re-runs the
67
+ // per-field validator which re-applies a real customValidity if needed.
68
+ if (typeof el.setCustomValidity === "function")
69
+ el.setCustomValidity("");
58
70
  el.dispatchEvent(new Event("input", { bubbles: true }));
59
71
  el.dispatchEvent(new Event("change", { bubbles: true }));
60
72
  // typeof el.checkValidity === "function" && !el.checkValidity();
@@ -165,8 +165,13 @@ export function validate(el, fn) {
165
165
  let customValidatorMessage = "";
166
166
  if (typeof customValidator === "function") {
167
167
  customValidatorMessage = customValidator(el.value, context, el) || "";
168
- el.setCustomValidity(customValidatorMessage);
169
168
  }
169
+ // Always write — including the no-validator case (which writes "" and
170
+ // thus clears any stale `customError` flag the element may be carrying
171
+ // from a prior listener generation). Without this, a `customValidator`
172
+ // being removed across re-renders would leave the previous message
173
+ // stuck on the element forever.
174
+ el.setCustomValidity(customValidatorMessage);
170
175
  // this triggers the bubble, which is not what we want
171
176
  // el.reportValidity();
172
177
  const validityState = el.validity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "3.76.1",
3
+ "version": "3.76.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",