Deprecate types search and password from TextField
Signed-off-by: Hermione Bird <hermioneb@spotify.com>
This commit is contained in:
@@ -48,6 +48,20 @@ export const TextField = forwardRef<HTMLDivElement, TextFieldProps>(
|
||||
}
|
||||
}, [label, ariaLabel, ariaLabelledBy]);
|
||||
|
||||
useEffect(() => {
|
||||
const inputType = (props as { type?: string }).type;
|
||||
if (inputType === 'search') {
|
||||
console.warn(
|
||||
'TextField type="search" is deprecated. Use SearchField instead.',
|
||||
);
|
||||
}
|
||||
if (inputType === 'password') {
|
||||
console.warn(
|
||||
'TextField type="password" is deprecated. Use PasswordField instead.',
|
||||
);
|
||||
}
|
||||
}, [props]);
|
||||
|
||||
const { classNames, dataAttributes } = useStyles('TextField', {
|
||||
size,
|
||||
});
|
||||
|
||||
@@ -23,6 +23,22 @@ import type { FieldLabelProps } from '../FieldLabel/types';
|
||||
export interface TextFieldProps
|
||||
extends AriaTextFieldProps,
|
||||
Omit<FieldLabelProps, 'htmlFor' | 'id'> {
|
||||
/**
|
||||
* The HTML input type for the text field
|
||||
*
|
||||
* @remarks
|
||||
* The values 'search' and 'password' are deprecated. Use `SearchField` for
|
||||
* search inputs and `PasswordField` for password inputs.
|
||||
*/
|
||||
type?:
|
||||
| 'text'
|
||||
| 'email'
|
||||
| 'tel'
|
||||
| 'url'
|
||||
/** @deprecated Use `SearchField` instead */
|
||||
| 'search'
|
||||
/** @deprecated Use `PasswordField` instead */
|
||||
| 'password';
|
||||
/**
|
||||
* An icon to render before the input
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user