Skip to content
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

Merged

Conversation

dwjohnston
Copy link
Contributor

@dwjohnston dwjohnston commented Mar 24, 2023

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 level disabled property. The logic I've gone for is a simple OR operator between these values. You could argue that the ui:submitButtonProps should always take precedence, even if set to false, but I can't think of a scenario where that makes sense.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@heath-freenome
Copy link
Member

@dwjohnston Have you had a chance to look over my feedback?

Comment on lines 299 to 314
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;
Copy link
Member

@heath-freenome heath-freenome Mar 31, 2023

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

@@ -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' },
Copy link
Member

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

CHANGELOG.md Outdated Show resolved Hide resolved
@dwjohnston dwjohnston force-pushed the bugfix-disable-submit-button branch from a725f1d to 8e0a83f Compare April 5, 2023 03:30
CHANGELOG.md Outdated Show resolved Hide resolved
@dwjohnston dwjohnston force-pushed the bugfix-disable-submit-button branch from b2c2aef to dc2341c Compare April 5, 2023 04:24
@heath-freenome heath-freenome merged commit abe63f3 into rjsf-team:main Apr 5, 2023
@dwjohnston dwjohnston deleted the bugfix-disable-submit-button branch April 6, 2023 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabling the form should disable the submit button as well.
2 participants