Skip to content

Conversation

@PascalVorwerk
Copy link
Collaborator

Pull Request

📖 Description

I came across #2882 and thought this was an interesting proposal. In my own applications i have felt the need to set the minimum to 0 without allowing the user to go below it! Now to my supprise, the current implementation actually has some bugs (in my eyes):

  • If one does not provide a min or max property to the numberfield, you can go over or below the minimum and max values for this type. So for example a short value could over its max:

image

This makes type safety not really a thing.. So my proposal would be to 'enforce' the minimum and maximum values of each type by using the min/max values of the type as a default parameter. @vnbaaij already made a nice helper method to get these minimum and maximum values for each type.

  • The old code would not validate the minimum and maximum value parameters if one of them was null, but i think this is wrong behaviour. I would say a 'Typed' number should always have a minimum and maximum value, even if that value is unbelievably large or small. So i think if either one of them is set to null by a user, the system should throw an exception.

🎫 Issues

#2882

👩‍💻 Reviewer Notes

I've had to custom check for the unsigned integers and parse them separately because the BindConverter of AspNetCore does not implement extension methods for these types. I could not extend the BindConvert because for some reason it gave me a sealed error, so i am manually checking for the types, after first trying it with the BindConvert. Let me know if you guys think this is a wrong approach!

📑 Test Plan

I have added some tests and examples to the projects. The tests validate the new Min/max parameters. I've had to regenerate the verified files because now each fluent-number-input component will always have a min/max by default generated.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

@PascalVorwerk
Copy link
Collaborator Author

Im sorry i am not sure why the commits of my previous pull request are included as commits... Can i somehow undo that? Or is it not a problem?

@rpodevns
Copy link
Contributor

Another issue with default Min and Max is that it could break existing CSS, such as:

fluent-number-field:has([min]) {
    border: 1px solid red;
}

MinLength = 1 likely ensures no blank values and MaxLength = 14 will prevent excessively long numbers because the fluent-number-field web component is `type="text".

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.

4 participants