From d88bdc368b68264aae5aa211b08e813efd98470c Mon Sep 17 00:00:00 2001 From: Jeroen Reumkens Date: Wed, 5 Oct 2022 16:22:06 +0200 Subject: [PATCH] Ensure we have to correct tabindexes for addons. Before addons AFTER the input still would get tab focus before the input. (#4849) --- packages/ui/v2/core/form/fields.tsx | 51 ++++++++++++++++++----------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/packages/ui/v2/core/form/fields.tsx b/packages/ui/v2/core/form/fields.tsx index 16314158ba..0a0f6464eb 100644 --- a/packages/ui/v2/core/form/fields.tsx +++ b/packages/ui/v2/core/form/fields.tsx @@ -164,6 +164,26 @@ type InputFieldProps = { labelClassName?: string; }; +type AddonProps = { + children: React.ReactNode; + isFilled?: boolean; + className?: string; + error?: boolean; +}; + +const Addon = ({ isFilled, children, className, error }: AddonProps) => ( +
+
+ {children} +
+
+); + const InputField = forwardRef(function InputField(props, ref) { const id = useId(); const { t: _t, isLocaleReady, i18n } = useLocale(); @@ -200,26 +220,12 @@ const InputField = forwardRef(function InputF )} {addOnLeading || addOnSuffix ? ( -
-
-
- {addOnLeading || addOnSuffix} -
-
+
+ {addOnLeading && ( + + {addOnLeading} + + )} (function InputF {...passThrough} ref={ref} /> + {addOnSuffix && ( + + {addOnSuffix} + + )}
) : (