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

The "name" attribute of inputs and controls(TypeScript) #287

Closed
SuperChocoman7 opened this issue Aug 18, 2018 · 1 comment
Closed

The "name" attribute of inputs and controls(TypeScript) #287

SuperChocoman7 opened this issue Aug 18, 2018 · 1 comment

Comments

@SuperChocoman7
Copy link

RMWC or MDC?

RMWC

What RMWC Version are you using?

1.8.3

What browser(s) and React Version is this bug affecting?

All

What build system are you using?

Create React App (TypeScript)

What is the expected behavior?

The input element of html has "name" attribute, which is usually used to handle the change of value.
For example, assumed I have an input element:

<input name="address" type="text" />

And a handleChange function:

handleChange(e: any) {
    const { name, value } = e.target;
    //Do something with name and value.
}

Then I can bind the onChange event to my handleChange function:

<input name="address" type="text" onChange={this.handleChange} />

What is the actual behavior?

The inputs and controls of RMWC(TextField, Checkbox, Select, Radio...) currently have no "name" attribute.

Any other information you believe would be useful?

However, I am able to use some tricks to achieve this in TypeScript.
Here's how I do it:

(TS part)

const nameAttr = { name: "address" };

(HTML Part)

<TextField {...nameAttr} type="text" onChange={this.handleChange} />

Is it possible to add "name" attribute on the inputs and controls of RMWC?
That would be a more proper way to handle changes of inputs and controls.

@jamesmfriedman
Copy link
Collaborator

Thanks for reporting this. Took me a bit to figure out that HTMLAttributes doesn't do anything... Got this properly working and applied the same fix to all of the input elements in RMWC.

Will post a patch sometime today.

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

No branches or pull requests

2 participants