Perspective - textfield - cancel change when disabling

I'm on 8.1.41

Is there a way to cancel modification on a textfield object with deferUpdates when the object is disabling during composition ?

I want to rollback to the initial value when the enable pass to false when a user is doing modification to the value and the update is not done.

You'd need to always store the last committed value of the field in a custom property. When you attempt to disable the field you'll need to disable the field and then write the last committed value to the property (if it doesn't already match). Note that this will still result in the value being typed by the user to be momentarily applied as the value of the field, so you'll have to be extra careful in how you store and apply the "last committed value".

I already tried that, but with the deferUpdates option it looks like the textfield stay in "edit mode" when I put the enabled to false and i'm not able to write back the initial value into the text property

My textfield is binded on a tag, so I just want to cancel the modification into the texfield before updating the tag...

Hmmm. you might need to force a loss of focus on the field. Let me see try to set up this scenario.

Here's what i found:
The disabling of the component in my setup correctly disabled the component even while a user was actively typing. The component was no longer in "edit" mode. The value the user had typed into the field remained in place in this disabled state, but was never "committed" or supplied in any way as a property value. I don't see a way to remove what the user typed into the input (though, again, it was never applied to any property); attempts to write the "last committed" value would be unsuccessful in clearing the typed value because the "last committed" value is equivalent to what the component believes its value to be at this time anyway.

The avenue to force a loss of focus before disabling the component would - I believe - cause the user's in-progress value to be supplied/committed before then allowing you to replace it with the last committed value, but... it's still an open feature request anyway, so it can't be used today.

1 Like