#17361 closed defect (worksforme)
onChange fires with set("value", ..., false) when intermediateChanges on
Reported by: | Stephen Chung | Owned by: | Douglas Hays |
---|---|---|---|
Priority: | undecided | Milestone: | tbd |
Component: | Dijit - Form | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
In particular, TextBox? fires onChange even when using set("value", "something", false) if intermediateChanges is true. If intermediateChanges is false, then onChange doesn't fire when the third parameter to "set" is false.
Attachments (2)
Change History (11)
comment:1 Changed 7 years ago by
Owner: | set to Douglas Hays |
---|---|
Status: | new → assigned |
comment:2 Changed 7 years ago by
comment:3 Changed 7 years ago by
onChange also fires when clicking the mouse inside the input box and then clicking somewhere else to remove the caret without changing the text inside the input box.
Perhaps the textbox needs to check the text against _LastValueReported before raising onChange...
comment:4 Changed 7 years ago by
Resolution: | → worksforme |
---|---|
Status: | assigned → closed |
I don't see the problem. intermediateChanges:true means that both low and high priority changes cause onChange to fire. The 3rd parameter to set/value sets the priority to low which is the same as using true due to intermediateChanges:true. If there's a separate issue, then please describe the recreate steps using my attached test file, or else attach another test file.
comment:5 Changed 7 years ago by
I understand the low priority part, but having onChange fires on TextBox? when the user has moved a caret (without changing the text), or even clicking on/out with the mouse sort of totally distorts what "Change" means... Therefore, it fires when there is no change at all, not just for low-priority changes.
The TextBox? probably fires onChange upon *any* suspicious event, including key presses (which may end up deleting part of the text for example). This is a bit counter-intuitive though...
comment:6 Changed 7 years ago by
Hi, I've uploaded a revised test file.
- Click on the text box, then click outside of it. onChange fires.
- Refresh. Click on the textbox, move the caret by pressing an arrow key. onChange fires. Doesn't fire on subsequent arrow keys.
I've isolated the culprit to the following:
textbox.set("intermediateChanges", false); textbox.set("value", "...", false); textbox.set("intermediateChanges", true);
comment:7 Changed 7 years ago by
This is a corner case. When the set/value/false executes, then there's a pending onChange that will fire eventually (possibly onblur). The priorityChange=false just means to not be in a hurry in call onChange. Obviously a blur event needs to fire onChange since the widget is no longer active. Then you set intermediateChanges=true which means to be in a hurry from now on. The widget does detect that something "could" have changed when you press keys, and then detects that there's a pending change so it assumes it's likely that something did in fact change. Since the web developer wants to be notified of all changes and there's a pending change, it seems reasonable that onChange fires. The only change in behavior that I think is reasonable is to fire onChange when intermediateChanges is set to true if there's already a pending change. But it's probably not worth the code bloat since it'll fire at blur anyway (or sooner).
comment:8 Changed 7 years ago by
OK, in that case, how can I ever set the text of the TextBox? without triggering onChange when intermediateChanges is on? For example, if I want a textbox to change color whenever somebody makes it dirty, I need to have intermediateChanges set to true. However, this means that I can't reset the value of the textbox without triggering onChange. If I set intermediateChanges temporarily to false like in my example to get around it, I get caught in the corner case.
I suppose what I want to do is a pretty rational use case...
A lot of comments on the web suggests comparing against _LastValueReported, but it seems like a hack to me... I can't believe that the "official" way to implement the use case is to do this...
comment:9 Changed 7 years ago by
Same problem with intermediatechanges and onchange event. It fires when I change focus without data modification. (dijit/form/Textarea). It is a bug. And dojox form manager is buggy too, I am not able to use it, function is not invoke by observer.
A related issue:
onChange also fires upon moving the caret via the arrow keys when intermediateChanges is set to true...