Form drops the submit event when a submitInterceptor is set
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- accessibility, frontend
Research direction
Start in Form.tsx at the onSubmit wrapper shown in the issue, then find the SubmitInterceptor type and the tests covering form submission and interceptors. Check how the submit event is passed to handlers when no interceptor is set, and compare that behavior with the intercepted path. Done when an interceptor can access and forward the event, and tests cover the submitter being available to the handler.
Written by the indexing model from the issue text.
Description
Problem
When a submitInterceptor is set via FormSettingsProvider, Form drops the submit event:
// Form.tsx
const onSubmit = submitInterceptor
? (values) => submitInterceptor(onSubmitProp, values, { form })
: onSubmitProp;
onSubmit(values, event) is still called with the event, but the wrapper only forwards values. The SubmitInterceptor type has no event parameter either, so an interceptor cannot pass it on to submit.
Impact
Handlers that read the pressed submit button from the event (event.nativeEvent.submitter) always get undefined as soon as an interceptor is active. In mStudio every modal is wrapped in a FormSettingsProvider with an interceptor (modal analytics), so forms with a second submit button ("Save and create another", name="submitKeepOpen") can no longer tell which button was pressed – the modal always closes.
An interceptor also cannot see which button was used, e.g. to track it.
Proposal
Forward the event to the interceptor and add it to the type:
export type SubmitInterceptor = <F extends FieldValues = FieldValues>(
submit: FormOnSubmitHandler<F>,
values: F,
context: SubmitInterceptorContext<F> & { event?: BaseSyntheticEvent },
) => ReturnType<FormOnSubmitHandler<F>>;
const onSubmit = submitInterceptor
? (values, event) => submitInterceptor(onSubmitProp, values, { form, event })
: onSubmitProp;
Interceptors then call submit(values, event).
Seen in @mittwald/flow-react-components 1.5.22, still present in 1.5.27.
- Dominant language
- TypeScript
- Stars
- 15
- Forks
- 4
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 197
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mittwald/flow
-
docs(agents): state which release line a change belongs to next to the migration catalogue ruleOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mittwald/flow#3205 · 1 comment ·
Maintainers usually reply within 1 day
-
next has fallen behind main (forward-merge drift)Possibly taken @Lisa18289 claimed this today. Openautomated
mittwald/flow#3554 · 1 assignee ·
Maintainers usually reply within 1 day
-
Make the decorative Semantic colors more colorful for AccentBox, Avatar and BadgePossibly taken @Jan-Eimertenbrink claimed this today. Openwayfinder:grilling
mittwald/flow#3550 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
chaitin/MonkeyCode#1437 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
carbon-design-system/carbon-ai-chat#2615 ·
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
redhat-developer/rhdh-plugin-export-overlays#4486 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offlinePossibly taken @r2jaff claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ComposioHQ/composio#5054 ·
Maintainers usually reply within 1 day