fix(forms): keep inline validation errors rendering on empty submit #410

Merged
YousifShkara merged 1 commit from fix/MAPPS-347-form-validation-inline-errors into main 2026-07-02 09:32:56 +02:00
Owner

dfb12cb added two shared handlers to the Input component's element that always installed regardless of whether the call site opted in: onkeydown: move |e| props.onkeydown.call(e) (default no-op) and onmounted: move |e| { if props.autofocus { spawn(...) } }. Both were meant to be backward-compatible passthroughs for GlobalSearch's collapse-on-click expand pattern (autofocus the entry, Escape to collapse). In practice, installing them on every Input instance broke the inline-error rendering path on the ticket-create form: submitting an empty form set title_error to "Title is required." but the corresponding <p class="text-red-600"> slot never rendered, which took mokosh-server's form-validation.spec.ts red on staging (PMS-518 AC7). MAPPS-347 tracks the regression.

Isolate the fix to the two files dfb12cb touched:

  • Drop the autofocus and onkeydown props from InputProps and stop installing the two always-on handlers on the underlying <input> element. Every existing consumer (dozens of forms across the SPA) reverts to the pre-dfb12cb behavior that PMS-518 was built against.
  • Re-implement GlobalSearch's autofocus + Escape without reaching into the shared component. Focus lives in a use_effect gated on the expanded() signal that grabs the input by id and calls HtmlElement::focus() after commit. Escape lives on the wrapper div's onkeydown (keydown bubbles up from the focused input, same pattern the modal uses on its container).

The mokosh-server-side test.fixme that PMS-591 landed to un-block its own merge un-fixmes in a matching PR once this SPA fix ships.

#MAPPS-347

dfb12cb added two shared handlers to the Input component's <input> element that always installed regardless of whether the call site opted in: `onkeydown: move |e| props.onkeydown.call(e)` (default no-op) and `onmounted: move |e| { if props.autofocus { spawn(...) } }`. Both were meant to be backward-compatible passthroughs for GlobalSearch's collapse-on-click expand pattern (autofocus the entry, Escape to collapse). In practice, installing them on every Input instance broke the inline-error rendering path on the ticket-create form: submitting an empty form set title_error to "Title is required." but the corresponding `<p class="text-red-600">` slot never rendered, which took mokosh-server's form-validation.spec.ts red on staging (PMS-518 AC7). MAPPS-347 tracks the regression. Isolate the fix to the two files dfb12cb touched: - Drop the `autofocus` and `onkeydown` props from InputProps and stop installing the two always-on handlers on the underlying `<input>` element. Every existing consumer (dozens of forms across the SPA) reverts to the pre-dfb12cb behavior that PMS-518 was built against. - Re-implement GlobalSearch's autofocus + Escape without reaching into the shared component. Focus lives in a `use_effect` gated on the `expanded()` signal that grabs the input by id and calls `HtmlElement::focus()` after commit. Escape lives on the wrapper div's `onkeydown` (keydown bubbles up from the focused input, same pattern the modal uses on its container). The mokosh-server-side test.fixme that PMS-591 landed to un-block its own merge un-fixmes in a matching PR once this SPA fix ships. #MAPPS-347
fix(forms): keep inline validation errors rendering on empty submit
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 1m15s
Create release / Create release from merged PR (pull_request) Has been skipped
39872abebb
dfb12cb added two shared handlers to the Input component's <input> element that always installed regardless of whether the call site opted in: `onkeydown: move |e| props.onkeydown.call(e)` (default no-op) and `onmounted: move |e| { if props.autofocus { spawn(...) } }`. Both were meant to be backward-compatible passthroughs for GlobalSearch's collapse-on-click expand pattern (autofocus the entry, Escape to collapse). In practice, installing them on every Input instance broke the inline-error rendering path on the ticket-create form: submitting an empty form set title_error to "Title is required." but the corresponding `<p class="text-red-600">` slot never rendered, which took mokosh-server's form-validation.spec.ts red on staging (PMS-518 AC7). MAPPS-347 tracks the regression.

Isolate the fix to the two files dfb12cb touched:

- Drop the `autofocus` and `onkeydown` props from InputProps and stop installing the two always-on handlers on the underlying `<input>` element. Every existing consumer (dozens of forms across the SPA) reverts to the pre-dfb12cb behavior that PMS-518 was built against.
- Re-implement GlobalSearch's autofocus + Escape without reaching into the shared component. Focus lives in a `use_effect` gated on the `expanded()` signal that grabs the input by id and calls `HtmlElement::focus()` after commit. Escape lives on the wrapper div's `onkeydown` (keydown bubbles up from the focused input, same pattern the modal uses on its container).

The mokosh-server-side test.fixme that PMS-591 landed to un-block its own merge un-fixmes in a matching PR once this SPA fix ships.

#MAPPS-347
YousifShkara deleted branch fix/MAPPS-347-form-validation-inline-errors 2026-07-02 09:32:56 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!410
No description provided.