Use one handler method for each input in renamedlg

This commit is contained in:
Stefano Brilli 2021-07-19 15:06:46 +02:00
parent 3f82e121e2
commit a3a396a830
1 changed files with 9 additions and 6 deletions

View File

@ -77,11 +77,14 @@ export const RenameDialog = (props: {}) => {
const handleChange = useCallback(
(event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => {
if (event.target.id === 'name') {
dispatch(renameDialogActions.setCurrentName(event.target.value.substring(0, 120))); // MAX title length
} else {
dispatch(renameDialogActions.setCurrentFullWidthName(event.target.value.substring(0, 105)));
}
dispatch(renameDialogActions.setCurrentName(event.target.value.substring(0, 120))); // MAX title length
},
[dispatch]
);
const handleFullWidthChange = useCallback(
(event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => {
dispatch(renameDialogActions.setCurrentFullWidthName(event.target.value.substring(0, 105)));
},
[dispatch]
);
@ -134,7 +137,7 @@ export const RenameDialog = (props: {}) => {
onKeyDown={event => {
event.key === `Enter` && handleDoRename();
}}
onChange={handleChange}
onChange={handleFullWidthChange}
/>
)}
</DialogContent>