From a3a396a830e7ae1dd0da898c29deca69a0d5e045 Mon Sep 17 00:00:00 2001 From: Stefano Brilli Date: Mon, 19 Jul 2021 15:06:46 +0200 Subject: [PATCH] Use one handler method for each input in renamedlg --- src/components/rename-dialog.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/rename-dialog.tsx b/src/components/rename-dialog.tsx index 0f2d654..d306810 100644 --- a/src/components/rename-dialog.tsx +++ b/src/components/rename-dialog.tsx @@ -77,11 +77,14 @@ export const RenameDialog = (props: {}) => { const handleChange = useCallback( (event: React.ChangeEvent) => { - 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) => { + 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} /> )}