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

[TypeScript] Fix type of SelectInput classes prop #6456

Merged
merged 1 commit into from
Jul 21, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions packages/ra-ui-materialui/src/input/ResettableTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import {
IconButton,
TextField as MuiTextField,
TextFieldProps,
Theme,
} from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import ClearIcon from '@material-ui/icons/Clear';
import { InputProps, useTranslate } from 'ra-core';
import { ClassesOverride } from '../types';
import { Styles } from '@material-ui/styles';

/**
* An override of the default Material-UI TextField which is resettable
Expand Down Expand Up @@ -170,30 +172,31 @@ function ResettableTextField(props: ResettableTextFieldProps) {
);
}

const useStyles = makeStyles(
{
clearIcon: {
height: 16,
width: 0,
},
visibleClearIcon: {
width: 16,
},
clearButton: {
height: 24,
width: 24,
padding: 0,
},
selectAdornment: {
position: 'absolute',
right: 24,
},
inputAdornedEnd: {
paddingRight: 0,
},
export const resettableStyles: Styles<Theme, ResettableTextFieldProps> = {
clearIcon: {
height: 16,
width: 0,
},
visibleClearIcon: {
width: 16,
},
{ name: 'RaResettableTextField' }
);
clearButton: {
height: 24,
width: 24,
padding: 0,
},
selectAdornment: {
position: 'absolute',
right: 24,
},
inputAdornedEnd: {
paddingRight: 0,
},
};

const useStyles = makeStyles(resettableStyles, {
name: 'RaResettableTextField',
});

const handleMouseDownClearButton = event => {
event.preventDefault();
Expand Down
8 changes: 6 additions & 2 deletions packages/ra-ui-materialui/src/input/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
warning,
} from 'ra-core';

import ResettableTextField from './ResettableTextField';
import ResettableTextField, { resettableStyles } from './ResettableTextField';
import InputHelperText from './InputHelperText';
import sanitizeInputRestProps from './sanitizeInputRestProps';
import Labeled from './Labeled';
Expand All @@ -23,6 +23,7 @@ import {
useSupportCreateSuggestion,
SupportCreateSuggestionOptions,
} from './useSupportCreateSuggestion';
import { ClassesOverride } from '../types';

/**
* An Input component for a select box, using an array of objects for the options
Expand Down Expand Up @@ -350,6 +351,7 @@ const sanitizeRestProps = ({

const useStyles = makeStyles(
theme => ({
...resettableStyles,
input: {
minWidth: theme.spacing(20),
},
Expand All @@ -360,4 +362,6 @@ const useStyles = makeStyles(
export interface SelectInputProps
extends ChoicesInputProps<TextFieldProps>,
Omit<SupportCreateSuggestionOptions, 'handleChange'>,
Omit<TextFieldProps, 'label' | 'helperText'> {}
Omit<TextFieldProps, 'label' | 'helperText' | 'classes'> {
classes?: ClassesOverride<typeof useStyles>;
}