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

RFC: Form submition #1769

Closed
makarov-roman opened this issue Jun 14, 2017 · 4 comments
Closed

RFC: Form submition #1769

makarov-roman opened this issue Jun 14, 2017 · 4 comments

Comments

@makarov-roman
Copy link

Hi! Since semantic-ui force us to use Form component as wrapper to Input, TextArea etc, It would cool to set default hof callback to prevent page reload if action prop have not provided

(e, callback) => {
  !this.props.action && e.preventDefault()
   callback(e)
}
@levithomason
Copy link
Member

This sounds like a great idea, PRs welcome!

@levithomason
Copy link
Member

PR up.

@darkadept
Copy link

I'm wondering, does this have anything to do with this error I'm getting? I'm using React Formal (https://github.com/jquense/react-formal) and using it like this:

import {default as Formal} from 'react-formal'; //They both have a component called <Form>
import {Form, Button} from 'semantic-ui-react';

class Thing extends Component {
  handleSubmit = (data) => {
  }

  render() {
    return {
      <Form
        as={Formal}
        schema={mySchema}
        onSubmit={this.handleSubmit}
      >
        // fields here...
        <button type="submit">Submit</button>
      </Form>
    }
  }
}

When I go to submit I get the following error on the console:

Uncaught TypeError: e.preventDefault is not a function

Is Semantic UI doing something strange here?

@layershifter
Copy link
Member

layershifter commented Jun 23, 2017

@darkadept Nope, as I see react-formal doesn't pass event object as the first argument, I don't think that it's correct behaviour. However, I think we can easy fix this to make it compatible with following change in Form's onSubmit:

-if (!action) e.preventDefault()
+if (!action) _.invoke(e, 'preventDefault')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants