`BitNumberField` displayed value may be inconsistent with the actual current value
Is there an existing issue for this?
- [x] I have searched the existing issues
Describe the bug
When using contraints Min or Max (or Precission), inputting value out of bounds will display corrected value only for the first change. For example with max set to 10:
- After first 1000 input, corrected 10 is displ.ayed
- Entering 1000 again and submitting using enter will not display 10 although internally 10 should be the current value
The reason behind this seems to be that the component does not use :get and :set modifiers for binding.
Changing the code to use the modifiers seems to fix the issue:
<input @ref="InputElement" @attributes="@InputHtmlAttributes"
@onblur="HandleOnBlur"
@onfocus="HandleOnFocus"
@onkeydown="HandleOnKeyDown"
@onfocusin="HandleOnFocusIn"
@onfocusout="HandleOnFocusOut"
@onwheel="HandleOnMouseWheel"
form=""
min="@_min"
max="@_max"
name="@Name"
step="@_step"
id="@_inputId"
readonly="@(ReadOnly || IsInputReadOnly)"
required="@Required"
style="@Styles?.Input"
autofocus="@AutoFocus"
inputmode="@_inputMode"
placeholder="@Placeholder"
aria-labelledby="@_labelId"
@bind-value:get="@CurrentValueAsString"
@bind-value:set="val => Immediate ? HandleOnStringValueInputAsync(new ChangeEventArgs() { Value = val }) : HandleOnStringValueChangeAsync(new ChangeEventArgs() { Value = val })"
@bind-value:event="@(Immediate ? "oninput" : "onchange")"
disabled="@(IsEnabled is false)"
class="bit-nfl-inp@(Mode == BitSpinButtonMode.Spread ? " bit-nfl-cin" : "") @Classes?.Input"
autocomplete="@(AutoComplete ?? "off")"
type="text"
aria-valuemin="@_min"
aria-valuemax="@_max"
aria-describedby="@AriaDescription"
aria-valuenow="@(AriaValueNow ?? CurrentValue)"
aria-valuetext="@(AriaValueText ?? CurrentValueAsString)"
aria-disabled="@(IsEnabled is false)" />
Expected Behavior
The component should display the current value after correction and not the invalid out of bound value after value change.
Steps To Reproduce
Reproducible in the documentation examples.
- Enter value out of bounds
- Press enter
- Value clamped to the limits and displayed
- Enter out of bounds again
- Press enter
- Displayed value stays the same
Exceptions (if any)
No response
.NET Version
.net 10
Anything else?
No response
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
- [ ] Create Plan
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your .coderabbit.yaml:
issue_enrichment:
auto_enrich:
enabled: false
💬 Have feedback or questions? Drop into our discord!
Hello there! I'm a wiki 🤖.
Based on the content of this thread, I've found a potentially relevant wiki page for you!
I hope this helps!
Thanks for contacting us. We're investigating this issue. We'll let you know if it's possible to work on this issue.
The issue is accepted and planned. Resolving it will start ASAP.
@Greexter thank you for finding and filing this issue. it seems your suggested solution is correct. it would be much appreciated if you could submit a PR containing your solution for resolving this issue.