satoshipay / solar

🌞 Stellar wallet. Secure and user-friendly.
https://solarwallet.io
MIT License
191 stars 59 forks source link

Fix invalid price error in trading form #1248

Closed ebma closed 3 years ago

ebma commented 3 years ago

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.

andywer commented 3 years ago

@ebma Can we close #1251 now?

ebma commented 3 years ago

@andy not quite sure, let's maybe wait for an answer from @marcoachury, he could have meant something different.