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

[TextField] Add inputProps back #9604

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/src/pages/demos/pickers/TimePickers.js
Expand Up @@ -29,10 +29,8 @@ function TimePickers(props) {
InputLabelProps={{
shrink: true,
}}
InputProps={{
inputProps: {
step: 300, // 5 min
},
inputProps={{
step: 300, // 5 min
}}
/>
</form>
Expand Down
12 changes: 6 additions & 6 deletions pages/api/text-field.md
Expand Up @@ -21,16 +21,15 @@ on top of the following components:
If you wish to alter the properties applied to the native input, you can do as follow:

```jsx
const InputProps = {
inputProps: {
step: 300,
},
const inputProps = {
step: 300,
};

return <TextField id="time" type="time" InputProps={InputProps} />;
return <TextField id="time" type="time" inputProps={inputProps} />;
```

For advanced cases, please look at the source of TextField and consider either:
For advanced cases, please look at the source of TextField by clicking on the
"Edit this page" button above. Consider either:
- using the upper case props for passing values direct to the components.
- using the underlying components directly as shown in the demos.

Expand All @@ -50,6 +49,7 @@ For advanced cases, please look at the source of TextField and consider either:
| id | string | | The id of the `input` element. |
| InputLabelProps | object | | Properties applied to the `InputLabel` element. |
| InputProps | object | | Properties applied to the `Input` element. |
| inputProps | object | | Properties applied to the native `input` element. |
| inputRef | func | | Use that property to pass a ref callback to the native input component. |
| label | node | | The label content. |
| labelClassName | string | | The CSS class name of the label element. |
Expand Down
1 change: 1 addition & 0 deletions src/TextField/TextField.d.ts
Expand Up @@ -23,6 +23,7 @@ export interface TextFieldProps extends StandardProps<
id?: string;
InputLabelProps?: InputLabelProps;
InputProps?: InputProps;
inputProps?: InputProps['inputProps'];
inputRef?: React.Ref<any>;
label?: React.ReactNode;
labelClassName?: string;
Expand Down
17 changes: 11 additions & 6 deletions src/TextField/TextField.js
Expand Up @@ -24,16 +24,15 @@ import Select from '../Select/Select';
* If you wish to alter the properties applied to the native input, you can do as follow:
*
* ```jsx
* const InputProps = {
* inputProps: {
* step: 300,
* },
* const inputProps = {
* step: 300,
* };
*
* return <TextField id="time" type="time" InputProps={InputProps} />;
* return <TextField id="time" type="time" inputProps={inputProps} />;
* ```
*
* For advanced cases, please look at the source of TextField and consider either:
* For advanced cases, please look at the source of TextField by clicking on the
* "Edit this page" button above. Consider either:
* - using the upper case props for passing values direct to the components.
* - using the underlying components directly as shown in the demos.
*/
Expand All @@ -52,6 +51,7 @@ function TextField(props) {
helperTextClassName,
id,
InputLabelProps,
inputProps,
InputProps,
inputRef,
label,
Expand Down Expand Up @@ -92,6 +92,7 @@ function TextField(props) {
inputRef={inputRef}
onChange={onChange}
placeholder={placeholder}
inputProps={inputProps}
{...InputProps}
/>
);
Expand Down Expand Up @@ -186,6 +187,10 @@ TextField.propTypes = {
* Properties applied to the `Input` element.
*/
InputProps: PropTypes.object,
/**
* Properties applied to the native `input` element.
*/
inputProps: PropTypes.object,
/**
* Use that property to pass a ref callback to the native input component.
*/
Expand Down