From eef5462fa4114d2390e66210c681f90ebaef65cc Mon Sep 17 00:00:00 2001 From: Wiinxt Date: Thu, 16 Dec 2021 16:40:44 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20des=20d=C3=A9pendances=20des=20fon?= =?UTF-8?q?ctions=20onChange=20et=20onKeyDown,=20celle-ci=20ne=20se=20mett?= =?UTF-8?q?aient=20pas=20=C3=A0=20jour=20au=20changement=20des=20fonctions?= =?UTF-8?q?=20d'origine,=20ce=20qui=20causait=20un=20d=C3=A9calage=20d'uni?= =?UTF-8?q?t=C3=A9=20("=E2=82=AC=20/=20an"=20au=20lieu=20de=20"=E2=82=AC?= =?UTF-8?q?=20/=20mois")=20apr=C3=A8s=20un=20changement=20mensuel=20<>=20a?= =?UTF-8?q?nnuel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #1880 --- site/source/design-system/field/NumberField.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/site/source/design-system/field/NumberField.tsx b/site/source/design-system/field/NumberField.tsx index b4cd15c73..9b485afdf 100644 --- a/site/source/design-system/field/NumberField.tsx +++ b/site/source/design-system/field/NumberField.tsx @@ -153,19 +153,20 @@ function useKeepCursorPositionOnUpdate( const [selection, setSelection] = useState(null) const [value, setValue] = useState() const [rerenderSwitch, toggle] = useState(false) + const { onChange: inputOnChange, onKeyDown: inputOnKeyDown } = inputProps const onChange = useCallback( (e) => { const input = e.target setValue(input.value) setSelection(Math.max(0, input.selectionStart, input.selectionEnd)) toggle(!rerenderSwitch) - inputProps.onChange?.(e) + inputOnChange?.(e) }, - [rerenderSwitch, toggle, setValue, setSelection] + [inputOnChange, rerenderSwitch] ) const onKeyDown = useCallback( (e) => { - inputProps.onKeyDown?.(e) + inputOnKeyDown?.(e) const input = e.target if ( !( @@ -182,7 +183,7 @@ function useKeepCursorPositionOnUpdate( ) toggle(!rerenderSwitch) }, - [setSelection, rerenderSwitch, toggle] + [inputOnKeyDown, rerenderSwitch] ) useEffect(() => { const input = inputRef.current