bitplatform icon indicating copy to clipboard operation
bitplatform copied to clipboard

`BitNumberField` displayed value may be inconsistent with the actual current value

Open Greexter opened this issue 11 months ago • 5 comments

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:

Image

  1. After first 1000 input, corrected 10 is displ.ayed
  2. 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)" />

Image

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.

  1. Enter value out of bounds
  2. Press enter
  3. Value clamped to the limits and displayed
  4. Enter out of bounds again
  5. Press enter
  6. Displayed value stays the same

Exceptions (if any)

No response

.NET Version

.net 10

Anything else?

No response

Greexter avatar Dec 26 '25 15:12 Greexter

📝 CodeRabbit Plan Mode

Generate an implementation plan and prompts that you can use with your favorite coding agent.

  • [ ] Create Plan
Examples

🧪 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!

coderabbitai[bot] avatar Dec 26 '25 15:12 coderabbitai[bot]

Hello there! I'm a wiki 🤖.

Based on the content of this thread, I've found a potentially relevant wiki page for you!

✨ View Wiki Page

I hope this helps!

github-actions[bot] avatar Dec 26 '25 15:12 github-actions[bot]

Thanks for contacting us. We're investigating this issue. We'll let you know if it's possible to work on this issue.

msynk avatar Dec 26 '25 15:12 msynk

The issue is accepted and planned. Resolving it will start ASAP.

msynk avatar Dec 26 '25 17:12 msynk

@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.

msynk avatar Dec 26 '25 18:12 msynk