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

Disallow letter inputs in all number fields #470

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ashiskumar-1999
Copy link
Contributor

Currently, all the number fields on the trade page accept the characters. This PR covered disallowing all the character inputs in all the number fields.

Technical Description

PR Checklist

  • Has the pr been tested manually by at least 1 reviewer?
  • Has all feedback been addressed?
  • Are all tests and linters running without error?
  • Users cannot enter characters in number fields

Screenshots / Screen-recordings

Disallow all the character inputs in all the number fields.
@ashiskumar-1999 ashiskumar-1999 linked an issue Jun 21, 2022 that may be closed by this pull request
1 task
Copy link
Collaborator

@Walodja1987 Walodja1987 left a comment

Choose a reason for hiding this comment

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

While I can't enter characters anymore, it shows an error when trying to create a LIMIT order or fill market:

Translation of the error message. "Enter a valid value. The two closest valid values are 0 and 1"
image

Copy link
Collaborator

@juliankrispel juliankrispel left a comment

Choose a reason for hiding this comment

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

In order to allow html inputs that are floats (as in have decimal points) you need to add a step attribute - something like step="0.01" - you probably also want to add min="0" so the numbers can only be positive

…input field.

Also added the "min" property to allow positive number in input field.
Copy link
Collaborator

@Walodja1987 Walodja1987 left a comment

Choose a reason for hiding this comment

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

Thanks! While it works, the app seems to get laggy when you enter the price in Buy/Sell Limit

Further, are there any other fields where we would need to make this adjustment? Maybe on the Create page?

Copy link
Collaborator

@juliankrispel juliankrispel left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@@ -90,7 +90,7 @@ export default function BuyLimit(props: {
const nbrOptions = parseFloat(value)
if (!isNaN(nbrOptions)) {
setNumberOfOptions(nbrOptions)
if (pricePerOption > 0 && nbrOptions > 0) {
if (pricePerOption > 0 && nbrOptions > 0.0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesn't change anything

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.

Disallow letter inputs in all number fields
3 participants