-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix disable submit button #3537
Bugfix disable submit button #3537
Conversation
6de623c
to
e48ca03
Compare
packages/core/src/components/templates/ButtonTemplates/SubmitButton.tsx
Outdated
Show resolved
Hide resolved
@dwjohnston Have you had a chance to look over my feedback? |
e48ca03
to
a725f1d
Compare
const rawUiSchema: UiSchema<T, S, F> = ('uiSchema' in props ? props.uiSchema! : this.props.uiSchema!) || {}; | ||
|
||
const uiSchema = props.disabled | ||
? { | ||
...rawUiSchema, | ||
'ui:submitButtonOptions': { | ||
...rawUiSchema['ui:submitButtonOptions'], | ||
props: { | ||
...rawUiSchema['ui:submitButtonOptions']?.props, | ||
disabled: true, | ||
}, | ||
}, | ||
} | ||
: rawUiSchema; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand why this would seem like the right place to update the uiSchema
used everywhere. There is one problem with this approach. ui:submitButtonOptions
could also be defined as ui:options: { submitButtonOptions }
; The approach I suggested of providing a separately constructed uiSchema
just to the SubmitButton
handles either situation.
I would revert this whole change since the only use for submitButtonOptions
really is the SubmitButton
and move the code down in the the render and pass a one-off set of props just to the SubmitButton
packages/core/src/components/templates/ButtonTemplates/SubmitButton.tsx
Outdated
Show resolved
Hide resolved
@@ -32,7 +32,7 @@ const liveSettingsSchema: RJSFSchema = { | |||
type: 'object', | |||
properties: { | |||
liveValidate: { type: 'boolean', title: 'Live validation' }, | |||
disable: { type: 'boolean', title: 'Disable whole form' }, | |||
disabled: { type: 'boolean', title: 'Disable whole form' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got fixed in another PR
a725f1d
to
8e0a83f
Compare
8e0a83f
to
69ccf88
Compare
b2c2aef
to
dc2341c
Compare
Reasons for making this change
Fixes #3264
Also fixes an issue with the Playground where the 'Disable whole form' button does not work.
The disabled button can be controlled via the
ui:submitButtonProps
properties, or the top leveldisabled
property. The logic I've gone for is a simple OR operator between these values. You could argue that theui:submitButtonProps
should always take precedence, even if set to false, but I can't think of a scenario where that makes sense.Checklist
npm run test:update
to update snapshots, if needed.