Skip to content

Commit

Permalink
Fix: enhance DateInput component layout and improve Year input change…
Browse files Browse the repository at this point in the history
… handler
  • Loading branch information
jorged94 committed Nov 19, 2024
1 parent 91c540d commit ae334df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useMonitoringCallback } from '../../../hooks/useMonitoringHooks';

const Wrapper = styled.div`
display: flex;
flex-wrap: wrap;
&& > * {
margin-right: 2px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ const Year = React.forwardRef<HTMLInputElement, YearProps>(
const [value, setValue] = useState(date?.getFullYear() || '');

const onYearChange: React.ChangeEventHandler<HTMLInputElement> =
useMonitoringCallback((currentOnChange, event) => {
let year = event.target.value;
year = year.length > 4 ? year.slice(0, 4) : year;
setValue(year);
currentOnChange?.('year', year);
}, onChange);
useMonitoringCallback(
(currentOnChange, event: React.ChangeEvent<HTMLInputElement>) => {
let year = event.target.value;
year = year.length > 4 ? year.slice(0, 4) : year;
setValue(year);
currentOnChange?.('year', year);
},
onChange
);

const onYearKeyDown: React.KeyboardEventHandler<HTMLInputElement> =
useMonitoringCallback((currentOnKeyDown, ev) => {
Expand Down

0 comments on commit ae334df

Please sign in to comment.