Material-ui: Documentation for Button click

Created on 26 Aug 2017  路  5Comments  路  Source: mui-org/material-ui

Problem description

For v1 demo and api button documentation, mention onClick

Steps to reproduce

https://material-ui-1dab0.firebaseapp.com/demos/buttons/#flat-buttons
https://material-ui-1dab0.firebaseapp.com/api/button/

Versions

  • Material-UI: v1-beta

Issue Guidelines

Have a QUESTION? Please ask in [StackOverflow or gitter](http://tr.im/77pVj before opening an issue.

I'm posting an issue rather than asking on SO because I consider this a doc bug.

If you are having an issue with click events, please re-read the [README](http://tr.im/410Fg) (you did read the README, right? :-) ).

I am having an issue with click events and I did re-read the README, but if I'm too dumb to be able to find the answer, it's still (from my dumb perspective at least) a doc bug.

Description

The old version had explicit onClick properties for buttons. V1 seems not to. I'm guessing users can handle onclick however they like? Still, it would be nice not to have to search all over the docs and come to that conclusion as a result of not seeing anything. It would be user-friendly to add something explicit to demo and api docs for buttons that there's no onClick prop. The button demos just don't do anything--beyond their own animation stuff--on click, maybe at least the simplest example could pop up an alert or something.

I'm not fixing this in my own pull request because I might be misunderstanding. But if someone tells me what the new philosophy on click properties is (or points me to the explanation that I didn't see in the README), I'll be glad to fix it myself.

docs

Most helpful comment

That seems perfectly reasonable. But how about my suggestion of adding one simple onclick to one of the button demos? The main reason people use buttons is to trigger actions. The old version handled that explicitly. I doubt I'll be the only person to waste time trying to figure out how to handle it now. Thanks.

All 5 comments

The key is into this sentence of the API documentation Any other properties supplied will be spread to the root element.. We don't document native properties that you would find on a native element.

That seems perfectly reasonable. But how about my suggestion of adding one simple onclick to one of the button demos? The main reason people use buttons is to trigger actions. The old version handled that explicitly. I doubt I'll be the only person to waste time trying to figure out how to handle it now. Thanks.

@Sigfried Sure, why not. We can have one onClick example. Do you want to submit a PR? It could trigger a console.log for instance.

I haven't been able to figure out how to fix these eslint errors:

47:15  error  Property should be placed on a new line                                         react/jsx-first-prop-new-line
47:41  error  Replace `鈴幝仿仿仿仿仿仿仿穙nClick={doSomething}鈴幝仿仿仿仿仿仿穈 with `路onClick={doSomething}`  prettier/prettier

The offending lines are:

  <Button className={classes.button}
    onClick={doSomething}
    data-something="here I am">
    Does something
  </Button>

Looks like you fixed it, or are in the middle of fixing it. Thanks. If there's anything else I need to do, let me know.

Was this page helpful?
0 / 5 - 0 ratings