2019-11-19 06:37:36 +07:00
|
|
|
import React from "react";
|
2021-01-02 17:58:24 +07:00
|
|
|
|
2019-11-19 06:37:36 +07:00
|
|
|
import { makeStyles } from "@material-ui/core";
|
2021-01-02 17:58:24 +07:00
|
|
|
import TextField, { TextFieldProps } from "@material-ui/core/TextField";
|
2019-11-19 06:37:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This component fixes outlined TextField
|
|
|
|
* https://github.com/mui-org/material-ui/issues/14530#issuecomment-463576879
|
2021-01-02 17:58:24 +07:00
|
|
|
*
|
2019-11-19 06:37:36 +07:00
|
|
|
* @param props the TextField props
|
|
|
|
*/
|
2020-11-07 09:06:18 +07:00
|
|
|
const FixedTextField = function (props: TextFieldProps) {
|
2019-11-19 06:37:36 +07:00
|
|
|
const style = useStyles();
|
|
|
|
return (
|
2021-01-02 17:58:24 +07:00
|
|
|
<TextField
|
|
|
|
{...props}
|
2019-11-19 06:37:36 +07:00
|
|
|
InputLabelProps={{
|
|
|
|
classes: {
|
2021-01-02 17:58:24 +07:00
|
|
|
root: style.label,
|
|
|
|
},
|
2020-11-09 10:04:44 +07:00
|
|
|
}}
|
2021-01-02 17:58:24 +07:00
|
|
|
inputProps={{ autoCapitalize: props.autoCapitalize }}
|
|
|
|
>
|
2019-11-19 06:37:36 +07:00
|
|
|
{props.children}
|
|
|
|
</TextField>
|
|
|
|
);
|
2021-01-02 17:58:24 +07:00
|
|
|
};
|
2019-11-19 06:37:36 +07:00
|
|
|
|
2021-01-02 17:58:24 +07:00
|
|
|
export default FixedTextField;
|
2020-11-07 09:06:18 +07:00
|
|
|
|
2021-01-02 17:58:24 +07:00
|
|
|
const useStyles = makeStyles((theme) => ({
|
2019-11-19 06:37:36 +07:00
|
|
|
label: {
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
paddingLeft: theme.spacing(0.1),
|
|
|
|
paddingRight: theme.spacing(0.1),
|
2021-01-02 17:58:24 +07:00
|
|
|
},
|
|
|
|
}));
|