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

SubmitField doesn't respect children #523

Closed
ChakirMrabet opened this issue Mar 31, 2019 · 2 comments
Closed

SubmitField doesn't respect children #523

ChakirMrabet opened this issue Mar 31, 2019 · 2 comments
Assignees
Labels
Type: Feature New features and feature requests

Comments

@ChakirMrabet
Copy link

ChakirMrabet commented Mar 31, 2019

For Material-UI, This:

<SubmitField>SAVE</SubmitField>

Still makes the button to show up with the text "SUBMIT", even though from the SubmitField source code I see that your intention was to show children when defined.

I think you have an error in your SubmitField code, this:

....
const SubmitField = ({children, disabled, inputRef, label, value, ...props}, {uniforms: {error, state}}) => (
  <Button
    disabled={disabled === undefined ? !!(error || state.disabled) : disabled}
    ref={inputRef}
    type="submit"
    value={value}
    {...filterDOMProps(props)}
  >
    {label || children}
  </Button>
);
SubmitField.contextTypes = BaseField.contextTypes;

SubmitField.defaultProps = {label: 'Submit', variant: 'contained'};

export default SubmitField;

Should be this:

...
const SubmitField = ({children, disabled, inputRef, label, value, ...props}, {uniforms: {error, state}}) => (
  <Button
    disabled={disabled === undefined ? !!(error || state.disabled) : disabled}
    ref={inputRef}
    type="submit"
    value={value}
    {...filterDOMProps(props)}
  >
    {children ? children : label}
  </Button>
);
SubmitField.contextTypes = BaseField.contextTypes;

SubmitField.defaultProps = {label: 'Submit', variant: 'contained'};

export default SubmitField;

{label || children} will be always label since it's defined as default.

I've tested and works.

@radekmie radekmie self-assigned this Mar 31, 2019
@radekmie radekmie added the Type: Feature New features and feature requests label Mar 31, 2019
@radekmie
Copy link
Contributor

radekmie commented Mar 31, 2019

Hi @ChakirMrabet. Indeed, there is a small inconsistency, especially between packages, as AntD and Material have their own components, and the rest is using simple <input type="submit">. Anyway, you can workaround this with label="" and using children, or using label directly.

It should be changed for the next version though. If you'd like to submit a PR for it, go ahead - just do it for the v2 branch.

@radekmie
Copy link
Contributor

It'll be part of the v2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features and feature requests
Projects
Archived in project
Development

No branches or pull requests

2 participants