Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridge back to stellar - max amount chosen by the user allow for the amount that is incompatible #506

Conversation

Sharqiewicz
Copy link
Collaborator

@Sharqiewicz Sharqiewicz commented Jun 25, 2024

What:

Context
When choosing 'Back to Stellar' and entering 'Max,' the amount prefilled by the system is half the available funds and correct, but the error message after the transaction is signed indicates that the amount is incompatible.

  • The system should choose compatible amount when user clicks "Max" and the transaction should succeed.
  • The system should prefill the maximum available amount with the correct decimal number limited to 7.

How:

✅ Implement maxDecimal to be also applied for StandardFrom AvailableActions

Copy link

netlify bot commented Jun 25, 2024

Deploy Preview for rococo-souffle-a625f5 ready!

Name Link
🔨 Latest commit 29ed49a
🔍 Latest deploy log https://app.netlify.com/sites/rococo-souffle-a625f5/deploys/66aa138d9d63e30008e03473
😎 Deploy Preview https://deploy-preview-506--rococo-souffle-a625f5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ebma
Copy link
Member

ebma commented Jun 26, 2024

I noticed another bug:

  1. Enter any amount with 7 decimals in the input field for issuing/redeeming with Spacewalk. Let's say: 1.1234567
  2. Put the input cursor anywhere in the input field.
  3. When entering a new digit, the cursor will jump to the end and replace the last digit. However, I should be able to add/change the digits in front of the ., even if the number already has 7 decimals.

@Sharqiewicz
Copy link
Collaborator Author

@ebma Excellent catch, I am working on it ✅

@annatekl
Copy link

@vadaynujra can you please test once done?

@Sharqiewicz
Copy link
Collaborator Author

@ebma I refactored the whole implementation of NumericInput events handling.

  • Fixed the onPaste event to restrict invalid values.
  • Unified event handling into a single onChange handler, reducing the code by 30 lines.
  • Enhanced and extended test cases for NumericInput.

Please take a look and let me know if everything is right.

@annatekl
Copy link

I was testing again on the same deployment link @Sharqiewicz and while manual input is correct the error with the cursor jumping to the last digit is still there and additionally when clicking on max there is the infinit number as in the attachementScreenshot 2024-06-26 at 19.27.24.png

@Sharqiewicz
Copy link
Collaborator Author

@annatekl The photo isn't loading. The cursor jumps to the end of the number only if the number already has a maximum decimal and the user overwrites a new number in decimal part (without using backspace first) - otherwise the cursor doesn't jump around. What is the expected behaviour here?

Now it works like this:
(max decimals is 7)
( | is the cursor )

  • User puts: 1.2345678|
  • User focus cursor between 2 and 3: 1.2|345678
  • User puts value 9: 1.2934567|

As the user tries to exceed the maximum number of decimal places, the decimal part of the number (starting from the changed second position) is moved by one. Therefore, the cursor has moved to the end, because the entire decimal part is changed

If user uses the backspace case:

  • User puts: 1.2345678|
  • User focus cursor between 2 and 3: 1.2|345678
  • User uses backspace: 1.|345678
  • User puts value 9: 1.9|34567

@vadaynujra
Copy link

Based on the explanation, I could imagine this to be the expected behavior. @ebma do you expect the cursor to stay at the same place also in the first case?

@ebma
Copy link
Member

ebma commented Jun 28, 2024

I think the input field works great now. @annatekl shared a screenshot where the input was filled with
2.5164e-8 after clicking the MAX button. I can't reproduce because I don't have an account with that balance.

@Sharqiewicz can we maybe have a test that simulates the behaviour of MAX when a user has a balance of 0.000000025164 (decimal) ie. a raw balance of 25,164 units?

…-by-the-user-allow-for-the-amount-that-is-incompatible
…om (NumericInput 50percent MAX buttons click)
@Sharqiewicz
Copy link
Collaborator Author

@ebma I fixed the issue with exponential notation and implemented test cases for it ✅

Copy link
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm 👍 I think it's all good now and we can merge.

My only concern is that the NumericInput component is nested quite deeply in the components/Form/From although it's also used in other places ie. Nabla. I think we should move this component out of these folders and put it more on the top level as it's a more general component.

@Sharqiewicz
Copy link
Collaborator Author

Works like a charm 👍 I think it's all good now and we can merge.

My only concern is that the NumericInput component is nested quite deeply in the components/Form/From although it's also used in other places ie. Nabla. I think we should move this component out of these folders and put it more on the top level as it's a more general component.

I absolutely agree. I will do it

@prayagd
Copy link
Collaborator

prayagd commented Jul 31, 2024

Screen.Recording.2024-07-31.at.12.38.31.PM.mov

Copy link
Collaborator

@prayagd prayagd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sharqiewicz

  • the cursor jumping error seems to be still there
  • also if i change the input to zero and then change to non-zero the error does not go away
  • max works as expected

@Sharqiewicz
Copy link
Collaborator Author

@prayagd I implemented the error validation when clicking on 50% and MAX, very good catch ✅
What do you mean by "the cursor jumping error seems to be still there"?

@prayagd
Copy link
Collaborator

prayagd commented Jul 31, 2024

You see in the video, when i am changing the first decimal instead of moving to the second decimal it jumps directly to the last decimal, personally find that a bit off but what do you guys think? @Sharqiewicz @ebma

@Sharqiewicz
Copy link
Collaborator Author

@annatekl The photo isn't loading. The cursor jumps to the end of the number only if the number already has a maximum decimal and the user overwrites a new number in decimal part (without using backspace first) - otherwise the cursor doesn't jump around. What is the expected behaviour here?

Now it works like this: (max decimals is 7) ( | is the cursor )

  • User puts: 1.2345678|
  • User focus cursor between 2 and 3: 1.2|345678
  • User puts value 9: 1.2934567|

As the user tries to exceed the maximum number of decimal places, the decimal part of the number (starting from the changed second position) is moved by one. Therefore, the cursor has moved to the end, because the entire decimal part is changed

If user uses the backspace case:

  • User puts: 1.2345678|
  • User focus cursor between 2 and 3: 1.2|345678
  • User uses backspace: 1.|345678
  • User puts value 9: 1.9|34567

@prayagd we already discussed it here

Copy link
Collaborator

@prayagd prayagd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops sorry missed it, we can go ahead and merge then. lesgo

@Sharqiewicz Sharqiewicz merged commit 5d3464b into main Jul 31, 2024
5 checks passed
@Sharqiewicz Sharqiewicz deleted the 503-bridge-back-to-stellar-max-amount-chosen-by-the-user-allow-for-the-amount-that-is-incompatible branch July 31, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bridge back to stellar - max amount chosen by the user allow for the amount that is incompatible
5 participants