Skip to content

Commit

Permalink
fix: input: fixes onchange handler of inputs (#120)
Browse files Browse the repository at this point in the history
* fix: input: fixes onchange handler of inputs

* chore: label: update label button height

* chore: input: add missed null check
  • Loading branch information
dkilgore-eightfold authored May 16, 2022
1 parent d83e790 commit 1076376
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/components/Inputs/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const TextArea: FC<TextAreaProps> = ({
const triggerChange = (
_event?: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
) => {
onChange;
onChange && onChange(_event);
};

return (
Expand Down
30 changes: 10 additions & 20 deletions src/components/Inputs/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,15 @@ export const TextInput: FC<TextInputProps> = ({
(
_event?: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
) => {
onChange;
const { target } = _event;

onChange && onChange(_event);

if (target?.value.length === 0 && clearButtonShown) {
setClearButtonShown(false);
} else if (!clearButtonShown) {
setClearButtonShown(true);
}
},
waitInterval
);
Expand All @@ -142,25 +150,7 @@ export const TextInput: FC<TextInputProps> = ({
maxLength={maxlength}
minLength={minlength}
name={name}
onChange={
!allowDisabledFocus
? (
_event?: React.ChangeEvent<
HTMLTextAreaElement | HTMLInputElement
>
) => {
handleChange;
if (
_event.target.value.length === 0 &&
clearButtonShown
) {
setClearButtonShown(false);
} else if (!clearButtonShown) {
setClearButtonShown(true);
}
}
: null
}
onChange={!allowDisabledFocus ? handleChange : null}
onBlur={!allowDisabledFocus ? onBlur : null}
onFocus={!allowDisabledFocus ? onFocus : null}
onKeyDown={!allowDisabledFocus ? onKeyDown : null}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Label/Label.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const Sizes = () => (
show: true,
toolTipContent: 'A tooltip',
toolTipPlacement: 'top',
onClick: () => _alertClicked(),
}}
size={LabelSize.Large}
text="Label"
Expand All @@ -27,6 +28,7 @@ export const Sizes = () => (
show: true,
toolTipContent: 'A tooltip',
toolTipPlacement: 'top',
onClick: () => _alertClicked(),
}}
size={LabelSize.Medium}
text="Label"
Expand All @@ -39,6 +41,7 @@ export const Sizes = () => (
show: true,
toolTipContent: 'A tooltip',
toolTipPlacement: 'top',
onClick: () => _alertClicked(),
}}
size={LabelSize.Small}
text="Label"
Expand Down
1 change: 1 addition & 0 deletions src/components/Label/label.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
border-radius: 100%;
box-sizing: border-box;
border-width: 1px;
height: 16px;
padding: 0;

&:active,
Expand Down

0 comments on commit 1076376

Please sign in to comment.