[javascript] Split form and non-form modals and support custom modal footers - #10695
[javascript] Split form and non-form modals and support custom modal footers#10695MaximeBICMTL wants to merge 3 commits into
Conversation
a5cae91 to
b2bd1ae
Compare
| }>; | ||
|
|
||
| export type FormModalProps = Omit<ModalProps, 'footer'> & { | ||
| onSubmit?: () => Promise<any> | any; |
There was a problem hiding this comment.
By splitting it into a specific FormModal I think we should require an onSubmit function to be passed. I can't think of a case where we would want a form with no submit function.
There was a problem hiding this comment.
Hhhhm, I initially kept FormModalProps the exact same to not break backwards compatibility, but I just checked and it does appear that all call sites provide an onSubmit prop, so I think your call is right.
I pushed a new commit that makes onSubmit mandatory and also improves the typing of onSubmit and onSuccess by using a generic type rather than any.
| onSuccess?: (data: any) => void; | ||
| title?: ReactNode; | ||
| width?: string; | ||
| footer?: ReactNode; |
There was a problem hiding this comment.
I'm a little hesitant to accept any ReactNode as a footer, but I do see the need for flexibility based on your examples... can you think of something more structured that we could implement? For example to make sure buttons stay bottom right, things are properly spaced, etc.
Now that I look at it, the same would apply for title. What do you think?
There was a problem hiding this comment.
Hhhhm, I think I disagree here. Even though most modals would use buttons as the footer, that may not always be the case, and I actually have one such footer in my examples. I think using ReactNode is fine, no need to be too restrictive for UI IMO.
e3a813d to
224da4c
Compare
Description
This PR refactors the LORIS modal to make two major changes:
Architecture
Modalcomponent fromjsx/Modals.tsxis split into three components:Modal: The general non-form modal, which allows the consumer to provide the body and optionally the footer.FormModal: The form modal, which is similar to the current modal and provides form and submit logic/controls.ModalFrame: common architecture between the two modals, technicallyFormModalcould also be made to depend directly uponModalbut this would require some higher-order component machinery because the form body and content should both be wrapper in aformelement, and this wrapper is undesirable in the general case.Examples
Showcase of existing modal behavior: (added artificial delay to showcase animations)
2026-06-29.18-08-33.mp4
Showcase of new non-form modals with custom footers:
2026-06-29.18-13-40.mp4