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

On the Chip onDelete event it doet not have target name #13543

Closed
Davidmycodeguy opened this issue Nov 7, 2018 · 3 comments
Closed

On the Chip onDelete event it doet not have target name #13543

Davidmycodeguy opened this issue Nov 7, 2018 · 3 comments
Labels
component: chip This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@Davidmycodeguy
Copy link

Davidmycodeguy commented Nov 7, 2018

Expected Behavior

When calling onDelete on a chip. The Event should bring back its proper name. 

Current Behavior

Returns Undefined. 

Steps to Reproduce

See https://codesandbox.io/s/j4qv2q0k85

Tech Version
@material-ui/core 3.4.0
@oliviertassinari
Copy link
Member

The workaround is to do:

import ReactDOM from "react-dom";
import React from "react";
import { Chip } from "@material-ui/core";

class App extends React.Component {
  checkListToggle = name => event => {
    alert(name);
  };
  render() {
    return (
      <div>
        <Chip
          name="keyName"
          label="keyname"
          color="primary"
          onDelete={this.checkListToggle('keyName')}
        />
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("root"));

@oliviertassinari oliviertassinari added support: question Community support but can be turned into an improvement component: chip This is the name of the generic UI component, not the React module! labels Nov 7, 2018
@Davidmycodeguy
Copy link
Author

Thank you for a response. I can do a workaround without a problem. However, that workaround it not allowed by es lint because of no-multi-assign. I just thought it might be a good idea to change the behavior. Not sure if its that big pressing issue for you guys.

@vshamgin
Copy link

try something like: onDelete={checkListToggle.bind(this, 'keyName')}
Worked in my case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: chip This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

3 participants