Skip to content

Commit

Permalink
Replace deprecated InputElement type
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Oct 29, 2024
1 parent 9f5535e commit 6f0e177
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
fireEvent,
userEvent,
} from '../../util/test-utils.js';
import type { InputElement } from '../Input/index.js';

import { ColorInput } from './ColorInput.js';

Expand All @@ -39,7 +38,7 @@ describe('ColorInput', () => {
});

it('should forward a ref', () => {
const ref = createRef<InputElement>();
const ref = createRef<HTMLInputElement>();
render(<ColorInput {...baseProps} ref={ref} />);
const [input] = screen.getAllByLabelText(baseProps.label);
expect(ref.current).toBe(input);
Expand Down
14 changes: 7 additions & 7 deletions packages/circuit-ui/components/ColorInput/ColorInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from 'react';

import { classes as inputClasses } from '../Input/index.js';
import type { InputElement, InputProps } from '../Input/index.js';
import type { InputProps } from '../Input/index.js';
import { clsx } from '../../styles/clsx.js';
import {
FieldLabelText,
Expand Down Expand Up @@ -65,7 +65,7 @@ export interface ColorInputProps
defaultValue?: string;
}

export const ColorInput = forwardRef<InputElement, ColorInputProps>(
export const ColorInput = forwardRef<HTMLInputElement, ColorInputProps>(
(
{
'aria-describedby': descriptionId,
Expand All @@ -91,16 +91,16 @@ export const ColorInput = forwardRef<InputElement, ColorInputProps>(
},
ref,
) => {
const colorPickerRef = useRef<InputElement>(null);
const colorInputRef = useRef<InputElement>(null);
const colorPickerRef = useRef<HTMLInputElement>(null);
const colorInputRef = useRef<HTMLInputElement>(null);

const labelId = useId();
const pickerId = useId();
const validationHintId = useId();

const descriptionIds = clsx(validationHintId, descriptionId);

const handlePaste: ClipboardEventHandler<InputElement> = (e) => {
const handlePaste: ClipboardEventHandler<HTMLInputElement> = (e) => {
if (!colorPickerRef.current || !colorInputRef.current || readOnly) {
return;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ export const ColorInput = forwardRef<InputElement, ColorInputProps>(
);
};

const onPickerColorChange: ChangeEventHandler<InputElement> = (e) => {
const onPickerColorChange: ChangeEventHandler<HTMLInputElement> = (e) => {
if (colorInputRef.current) {
colorInputRef.current.value = e.target.value.replace('#', '');
}
Expand All @@ -144,7 +144,7 @@ export const ColorInput = forwardRef<InputElement, ColorInputProps>(
}
};

const onInputChange: ChangeEventHandler<InputElement> = (e) => {
const onInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
if (colorPickerRef.current) {
colorPickerRef.current.value = `#${e.target.value}`;
}
Expand Down

0 comments on commit 6f0e177

Please sign in to comment.