Skip to content

Commit

Permalink
remove adornment classes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhochman committed Nov 20, 2020
1 parent aa3aea5 commit d1d72ad
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions frontend/packages/core/src/Input/text-field.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as React from "react";
import styled from "@emotion/styled";
import {
InputAdornment,
InputProps as MuiInputProps,
MuiStandardTextFieldProps,
TextField as MuiTextField,
} from "@material-ui/core";
import ClearIcon from "@material-ui/icons/Clear";
import ErrorIcon from "@material-ui/icons/Error";
import _ from "lodash";

Expand Down Expand Up @@ -85,18 +83,6 @@ const StyledTextField = styled(BaseTextField)({
width: "16px",
marginRight: "5px",
},

".MuiInputAdornment-root": {
display: "none",
},

".Mui-focused > .MuiInputAdornment-root": {
display: "inherit",
},

".MuiInputAdornment-root > svg": {
cursor: "pointer",
},
});

export interface TextFieldProps
Expand Down Expand Up @@ -131,12 +117,6 @@ export const TextField = ({
readOnly,
...props
}: TextFieldProps) => {
const [isEmpty, setIsEmpty] = React.useState(true);
const nestedOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setIsEmpty(_.isEmpty(e.target.value));
onChange && onChange(e);
};

const onKeyDown = (
e: React.KeyboardEvent<HTMLDivElement | HTMLTextAreaElement | HTMLInputElement>
) => {
Expand All @@ -148,6 +128,7 @@ export const TextField = ({
}
};

// Prepend a '!' icon to helperText displayed below the form if the form is in an error state.
if (error) {
helperText = (
<>
Expand All @@ -162,17 +143,9 @@ export const TextField = ({
onKeyDown={e => onKeyDown(e)}
onFocus={onChange}
onBlur={onChange}
onChange={nestedOnChange}
error={error}
helperText={helperText}
InputProps={{
readOnly,
endAdornment: !isEmpty && (
<InputAdornment position="end">
<ClearIcon onClick={() => console.log("ahhh")} />{" "}
</InputAdornment>
),
}}
InputProps={{ readOnly }}
{...props}
/>
);
Expand Down

0 comments on commit d1d72ad

Please sign in to comment.