cheogram-www
created pr with
cheogram-www/validate-form-on-execute.1
added cheogram-www/validate-form-on-execute.2
1: a03bb2b = 1: a03bb2b Use reportValidity to trigger browser validations
added cheogram-www/validate-form-on-execute.3
1: a03bb2b < -: ------- Use reportValidity to trigger browser validations
-: ------- > 1: c241180 Use reportValidity to trigger browser validations
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-www:validate-form-on-execute | git am -3checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:validate-form-on-execute [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:validate-form-on-executeadd comment to patch request:
ssh pr.pico.sh comment cheogram-www:validate-form-on-execute "lgtm!"
Patchset
cheogram-www/validate-form-on-execute.1
Use reportValidity to trigger browser validations
Eric Roberts
2026-11-20T17:04:41ZExcluded cancel and prev as you wouldn't want to have to fill in something just to cancel or go back. I'm assuming all other actions should be validated, but this may turn out to be a bad assumption, I'm not sure. Normally clicking a button of type submit would do this validation, and we add type submit to buttons for the first action. However because the execute then causes the button to not exist on the page, the event never makes it to the form. I tried moving execute to the form onSubmit, and then making the buttons be submit, so it would just trigger the default validation behaviour. But this had other problems like in ButtonGrid closing the dialog for custom input causes the button not to be rendered and the form submit not to happen. So this seems like the smallest change that is reasonable to make with what I know right now. I still don't love it.
Semantic diff summary
0 added,
0 modified,
0 signature changed,
0 removed
across 1 analyzed file
+7
-0
src/components/CommandSession.tsx
#
| ... | ... | @@ -34,6 +34,13 @@ const CommandSessionInner = ({ | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | 36 | const execute = (action: string | null) => { | |
| 37 | + | if ( | |
| 38 | + | !["cancel", "prev"].includes(action ?? "") && | |
| 39 | + | formRef.current?.reportValidity() === false | |
| 40 | + | ) { | |
| 41 | + | return; | |
| 42 | + | } | |
| 43 | + | ||
| 37 | 44 | const data = | |
| 38 | 45 | formRef.current && !form.isResult() | |
| 39 | 46 | ? new FormData(formRef.current) |