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

[UWP] Number less than the min returned in Input.Number when user input is more than double precision #5452

Closed
1 task
RebeccaAnne opened this issue Mar 2, 2021 · 3 comments
Assignees
Labels
Area-Inconsistency Bugs around renderer inconsistencies across different platforms Area-Inputs Bug Platform-XAML Bugs or features related to Xaml Renderer Resolution-Duplicate

Comments

@RebeccaAnne
Copy link
Contributor

Platform

What platform is your issue or question related to? (Delete other platforms).

  • UWP

Details

Using the card below, which has a min of 2.5, if the user inputs 2.4999999999999999, the validation passes and "2.4999999999999999" is returned as the value. Javascript and .NET also pass validation in this case, but both of those platforms return "2.5" in the submit (.NET updates the value in the UI to 2.5 as well). The JavaScript/.NET behavior is probably better here as we ideally don't want to send back number values technically less than the passed in min.

(I haven't tested the iOS/Android behavior)

Input.Number.Float.json:

{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.3",
	"body": [
		{
			"type": "Input.Number",
			"id": "number",
			"label": "Enter a number between 2.5 and 9.5",
			"min": 2.5,
			"max": 9.5,
			"value": 4.5,
			"errorMessage": "Invalid input. Ensure it's between 2.5 and 9.5, inclusive."
		}
	],
	"actions": [
		{
			"type": "Action.Submit",
			"title": "OK"
		}
	]
}

image

@RebeccaAnne RebeccaAnne added the Bug label Mar 2, 2021
@ghost ghost added this to the Short Term milestone Mar 2, 2021
@ghost ghost added the Triage-Needed label Mar 2, 2021
@golddove
Copy link
Member

golddove commented Mar 2, 2021

You could argue that it's preferable to leave the user input as-is, and let the bot consume it however it wishes (think: maybe a bot would like to support greater precision in their inputs. if we force-round the input, the bot is stuck with the precision we choose).

Whichever we think is the right behavior, I agree platforms should be consistent.

@RebeccaAnne RebeccaAnne added Area-Inconsistency Bugs around renderer inconsistencies across different platforms Area-Inputs labels Mar 2, 2021
@ghost ghost added Triage-Investigate and removed Triage-Needed labels Mar 3, 2021
@RebeccaAnne
Copy link
Contributor Author

You could argue that it's preferable to leave the user input as-is, and let the bot consume it however it wishes (think: maybe a bot would like to support greater precision in their inputs. if we force-round the input, the bot is stuck with the precision we choose).

I don't necessarily disagree with that, but in that case we'd ideally want to enforce the min/max without rounding. So our choices are:

  1. Do the number comparisons via conversion to double, but send the user data as is, violating the min (current UWP behavior)
  2. Do the number comparisons via conversion to double, and return the rounded value, reducing precision for the bot (current .NET/JavaScript behavior)
  3. Write some code to do the number comparisons on the string without converting the string to a number.

3 seems like more trouble than it's worth for this edge case. I'm comfortable with the idea that Input.Number doesn't support greater than double precision (unless someone is asking for it), especially given several of our platforms didn't do better than int until recently. And I think 2 is better than 1. Also, for what it's worth, the .NET xceed control is doing the rounding itself before we get a chance to intervene anyway.

@RebeccaAnne RebeccaAnne self-assigned this Mar 11, 2021
@RebeccaAnne RebeccaAnne removed this from the Short Term milestone May 6, 2021
@jonmill jonmill added Triage-Approved for Fix Platform-XAML Bugs or features related to Xaml Renderer and removed Triage-Investigate labels May 6, 2021
@jonmill
Copy link
Contributor

jonmill commented Nov 4, 2021

Dupe of / will be fixed by #5404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Inconsistency Bugs around renderer inconsistencies across different platforms Area-Inputs Bug Platform-XAML Bugs or features related to Xaml Renderer Resolution-Duplicate
Projects
None yet
Development

No branches or pull requests

3 participants