Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Fix: Prevent consecutive operator input in CalculatorModal #3359

Merged
merged 3 commits into from
Jul 22, 2024
Merged

Fix: Prevent consecutive operator input in CalculatorModal #3359

merged 3 commits into from
Jul 22, 2024

Conversation

akashs056
Copy link
Contributor

@akashs056 akashs056 commented Jul 22, 2024

Pull request (PR) checklist

Please check if your pull request fulfills the following requirements:

  • I've read the Contribution Guidelines and my PR doesn't break the rules.
  • I've read and understand the Developer Guidelines.
  • I confirm that I've run the code locally and everything works as expected.
  • My PR includes only the necessary changes to fix the issue (i.e., no unnecessary files or lines of code are changed).
  • 🎬 I've attached a screen recording of using the new code to the next paragraph (if applicable).

What's changed?

Resolved an issue in the CalculatorModal where consecutive operators could be added, resulting in invalid expressions.

  • Updated the handleOperator function to ensure only one operator is added at a time.
  • Replaced the last operator if a new operator is pressed.
  • Ensured the input behaves like a standard calculator.

This change improves the user experience by preventing invalid expressions and aligning the calculator's behavior with user expectations.

Before
https://github.com/user-attachments/assets/c4cb087d-e360-44b1-90fd-38f3436e5e04

After:
https://github.com/user-attachments/assets/085816dc-9ad7-459a-b48e-c35e3bd649ad

Resolved an issue in the CalculatorModal where consecutive operators could be added, resulting in invalid expressions.

- Updated the handleOperator function to ensure only one operator is added at a time.
- Replaced the last operator if a new operator is pressed.
- Ensured the input behaves like a standard calculator.

This change improves the user experience by preventing invalid expressions and aligning the calculator's behavior with user expectations.
Copy link
Collaborator

@ILIYANGERMANOV ILIYANGERMANOV left a comment

Choose a reason for hiding this comment

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

LGTM! Left some minor comments to resolve. Does it work for entering "-10"? Lots of people use it for adding negative balances

@akashs056
Copy link
Contributor Author

Does it work for entering "-10"

I dont get it .......

@ILIYANGERMANOV
Copy link
Collaborator

Does it work for entering "-10"

I dont get it .......

Can you input the following expression when adjusting balance?

-10.32

@akashs056
Copy link
Contributor Author

Does it work for entering "-10"

I dont get it .......

Can you input the following expression when adjusting balance?

-10.32
neg.mp4

If you mean this then yes

Copy link
Collaborator

@ILIYANGERMANOV ILIYANGERMANOV left a comment

Choose a reason for hiding this comment

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

Nice work! Fix the CI and we can merge

@akashs056
Copy link
Contributor Author

It's ready to merge

@ILIYANGERMANOV ILIYANGERMANOV merged commit 9e641eb into Ivy-Apps:main Jul 22, 2024
8 checks passed
@ILIYANGERMANOV
Copy link
Collaborator

@akashs056 you missed to add which is closed by this PR and now I have to manually go and close it. Not a big deal but so you know for future PRs

@akashs056 akashs056 deleted the akashs056-fix-issue-3357 branch July 22, 2024 11:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants