Skip to content

fix(DoubleUpDown): revert to previous value on out-of-range input with ClipValueToMinMax=false (fixes #1801)#1809

Open
JyslaFancy wants to merge 1 commit into
xceedsoftware:masterfrom
JyslaFancy:fix/1801-doubleupdown-revert-on-outofrange
Open

fix(DoubleUpDown): revert to previous value on out-of-range input with ClipValueToMinMax=false (fixes #1801)#1809
JyslaFancy wants to merge 1 commit into
xceedsoftware:masterfrom
JyslaFancy:fix/1801-doubleupdown-revert-on-outofrange

Conversation

@JyslaFancy

Copy link
Copy Markdown

Fixes #1801 — DoubleUpDown with ClipValueToMinMax=false silently truncates digits instead of reverting.

Problem

When ClipValueToMinMax=false and user enters an out-of-range value then tabs away (UpdateSourceTrigger=LostFocus), the control silently truncates digits. For example with Max=20000, typing 123456 sets the VM property to 12345.

Root cause

Intermediate valid values (e.g. 12345) were committed to the internal Value property during typing via SyncTextAndValueProperties. On LostFocus, when the final value was out of range, the catch block raised a validation error but the display text was reverted to the last committed intermediate value.

Fix

  1. Added _initialValueOnFocus field to save the Value when focus is gained
  2. In UpDownBase_IsKeyboardFocusWithinChanged, save this.Value on focus gain
  3. In the SyncTextAndValueProperties catch block, when !_isTextChangedFromUI and !ClipValueToMinMax, restore _initialValueOnFocus via SetValueInternal before raising the validation error

This ensures the control reverts to the correct pre-edit value instead of a truncated intermediate value.

…h ClipValueToMinMax=false

When ClipValueToMinMax=false and the user enters an out-of-range value
then tabs away (UpdateSourceTrigger=LostFocus), the control was silently
truncating digits to bring the value within Min/Max range. For example,
with Max=20000, typing 123456 would set the VM property to 12345 instead
of reverting to the original valid value.

Root cause: The intermediate valid values typed (e.g. 12345) were being
committed to the internal Value property during typing. On LostFocus,
when the final value (123456) was out of range, the text was reverted to
the last committed intermediate value instead of the pre-edit value.

Fix: Save the initial Value on focus gain (_initialValueOnFocus), and
restore it in the SyncTextAndValueProperties catch block when
ClipValueToMinMax=false and the user is not actively typing.

Fixes xceedsoftware#1801
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.

DoubleUpDown behaviour when ClipValueToMinMax = false

1 participant