Fixes a bug where the user cannot submit a trade order because the "Invalid price" error message is always shown if the user has not manually changed the price.
I removed the validation from the <Controller> component because the value that is passed here is not enough to check if a price is invalid. The reason for this is that the price input field does either contain the manualPrice (input by the user) or the defaultPrice that was calculated in the useCalculation hook. The validation function however receives only the manualPrice (that is 0 until the user edited the field manually) which is basically the root issue of the bug. I tried passing a validation function that uses the calculation results of the useCalculation hook but this does not work because the component is not rerendered and the function not up-to-date. That's why I put the validation into the submitForm() function.
Fixes a bug where the user cannot submit a trade order because the "Invalid price" error message is always shown if the user has not manually changed the price.
I removed the validation from the
<Controller>
component because the value that is passed here is not enough to check if a price is invalid. The reason for this is that the price input field does either contain themanualPrice
(input by the user) or thedefaultPrice
that was calculated in theuseCalculation
hook. Thevalidation
function however receives only themanualPrice
(that is 0 until the user edited the field manually) which is basically the root issue of the bug. I tried passing a validation function that uses the calculation results of theuseCalculation
hook but this does not work because the component is not rerendered and the function not up-to-date. That's why I put the validation into thesubmitForm()
function.