Skip to content

Commit

Permalink
Fix input event handler types
Browse files Browse the repository at this point in the history
  • Loading branch information
shoonia committed Dec 9, 2023
1 parent d3ebaee commit b6050ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/components/Jobs/FunctionInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { JSX } from 'preact';

import s from './styles.css';
import { KEYS } from '../../constants';
import { Label } from './Label';
import { useFormScope } from '../../hooks/formScope';
import { type TValidator, isValidFunctionLocation, isValidFunctionName } from '../../util/validator';

const validatorListener = (validator: TValidator): EventListener => {
const validatorListener = (validator: TValidator): JSX.InputEventHandler<HTMLInputElement> => {
return (event) => {
const el = event.target as HTMLInputElement;
const el = event.currentTarget;
const value = el.value.trim();

if (el.value !== value) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/TextBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { JSX } from 'preact';

import s from './styles.css';

interface Props {
onInput: EventListener
onInput: JSX.InputEventHandler<HTMLTextAreaElement>;
value?: string;
}

Expand Down
7 changes: 3 additions & 4 deletions src/components/UploadModal/UploadModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { JSX } from 'preact';
import { useRef } from 'preact/hooks';

import s from './styles.css';
Expand Down Expand Up @@ -43,10 +44,8 @@ export const UploadModal: FC = () => {
location.hash = ROUTER.VALIDATOR;
};

const onInput: EventListener = (event) => {
const el = event.target as HTMLTextAreaElement;

ref.current = el.value;
const onInput: JSX.InputEventHandler<HTMLTextAreaElement> = (event) => {
ref.current = event.currentTarget.value;
};

const onSubmit: EventListener = (event) => {
Expand Down
12 changes: 5 additions & 7 deletions src/components/Validator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { JSX } from 'preact';

import s from './styles.css';
import { useStoreon } from '../../store';
import { preventDefault } from '../../util/component';
Expand All @@ -9,15 +11,11 @@ import { TextBox } from '../TextBox';
export const Validator: FC = () => {
const { validatorValue, dispatch } = useStoreon('validatorValue');

const onInput: EventListener = (event) => {
const el = event.target as HTMLTextAreaElement;

dispatch('validator/input', el.value);
};
const onInput: JSX.InputEventHandler<HTMLTextAreaElement> = (event) =>
dispatch('validator/input', event.currentTarget.value);

const onLoad = (value: string): void => {
const onLoad = (value: string): void =>
dispatch('validator/input', value);
};

return (
<section className={s.page}>
Expand Down

0 comments on commit b6050ea

Please sign in to comment.