Skip to content

Commit

Permalink
code review: better event types
Browse files Browse the repository at this point in the history
  • Loading branch information
aversini committed Dec 2, 2023
1 parent ee6e072 commit 8baff39
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/ui-components/src/components/TextInput/TextInputMask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export const TextInputMask = React.forwardRef<
}
};

const handleShowMaskButtonClick = (e: any) => {
const handleShowMaskButtonClick = (
e: React.SyntheticEvent<Element, Event>,
) => {
e.preventDefault();
const newHiddenState = !isMaskedRef.current;
isMaskedRef.current = newHiddenState;
Expand All @@ -82,7 +84,9 @@ export const TextInputMask = React.forwardRef<
onMaskChange && onMaskChange({ e, masked: newHiddenState });
};

const handleTextInputMaskBlur = (e: any) => {
const handleTextInputMaskBlur = (
e: React.FocusEvent<HTMLInputElement | HTMLButtonElement, Element>,
) => {
const { relatedTarget } = e;
/**
* If the related target is not a child of the input,
Expand All @@ -97,18 +101,22 @@ export const TextInputMask = React.forwardRef<
}
};

const handleFieldBlur = (e: any) => {
const handleFieldBlur = (
e: React.FocusEvent<HTMLInputElement, Element>,
) => {
restartAutoMaskTimer();
onBlur && onBlur(e);
handleTextInputMaskBlur(e);
};

const handleFieldFocus = (e: any) => {
const handleFieldFocus = (
e: React.FocusEvent<HTMLInputElement, Element>,
) => {
restartAutoMaskTimer();
onFocus && onFocus(e);
};

const handleChange = (e: any) => {
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
restartAutoMaskTimer();
onChange && onChange(e);
};
Expand Down

0 comments on commit 8baff39

Please sign in to comment.