Hi, I tried to extend the TextLineStateless fields of the Form Engine with a React ref to handle the focus more precisely for our use case. Therefore I used a custom widget map:
export const CustomWidgetMap: WidgetMap = {
...DefaultWidgetMap,
TextLineStateless: (props: TextLineStatelessProps) => {
const fieldRef = useRef<HTMLElement | null>(null);
return <DefaultWidgetMap.TextLineStateless {...props} inputRef={ref => (fieldRef.current = ref)} />;
}
};
Unfortunately, after I added the inputRef to the component, it seems to have side effects regarding the validation of the fields.
Without inputRef: The Form Engine checks the field value as soon as the user leaves the input (onBlur).
With inputRef: The Form Engine checks the field value as soon as there’s user input. It doesn’t matter if the ref callback is defined or undefined. It happens just by using the prop.
In my case this leads to the following problem. I have a number field with minFractionalDigits - but it gets validated when I input the first number (without a blur). So this prevents me from entering a multi-digit number all by myself. When I enter a “1” then the validation instantly changes the value to “1.00”. The same if I try to backspace the last “0” of “1.00”.
Can anyone tell me why the validation is triggered in this case? Am I missing something?
I know it’s triggered by validatePartlyWith3ValueLogic in the <model>.validation.js. But I don’t know what causes it because setting a React ref shouldn’t change the state to begin with.
Thanks in advance for any useful information!