Opened 4 years ago
Last modified 4 years ago
#13298 closed defect
Autopreview triggers without a form change — at Initial Version
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2.6 |
Component: | ticket system | Version: | |
Severity: | normal | Keywords: | autopreview |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
To reproduce:
- Navigate to New Ticket. The Summary field will have focus.
- Open a select box or put the focus on another element. Autopreview will trigger.
The problem is due to two changes:
- In r13452 the workflow controls were added to the new ticket page. We added the create and assign action.
- In r13707 the
ticket_workflow
template was added and the associated JavaScript was moved into this template. !The JavaScript disables workflow inputs associated with actions that are not selected. Since jQuery ready handlers executed in the order they are added, this JavaScript executes after autoSubmit initializes.
With the default workflow, create
action will be selected when loading the New Ticket page.
The autoSubmit
will initialize and collect a list of all inputs which will includes the #action_create_and_assign_reassign_owner
select.
Any of the events input cut paste keydown keypress change blur
will trigger the callback, because the new array of form elements will be one-less than that which was originally stored.
I tried to solve this in several ways by executing the JavaScript in ticket_workflow.html
immediately after the elements are created rather than adding a document ready handler. This results in a flicker in which the element is shown for milliseconds without being disabled. So I tried hiding the entire form element until the JavaScript is executed. It's a bit messy.
Or we could move the script
block in ticket.html
to the end of the page.
It looks like we can just initialize values
on the first trigger, because we trigger on element losing focus blur
as well as keydown, so values
gets initialized before any elements of the form are changed.
-
trac/htdocs/js/auto_preview.js
diff --git a/trac/htdocs/js/auto_preview.js b/trac/htdocs/js/auto_preview.js index a1dfd1bd9..e6e5f31bb 100644
a b 28 28 var timer = null; 29 29 var updating = false; 30 30 var queued = false; 31 var values = null; 31 32 32 33 // Return true iff the values have changed 33 34 function values_changed(new_values) { … … 81 82 82 83 // Trigger a request after the given timeout 83 84 function trigger() { 85 if (values === null) 86 values = form.serializeArray(); 84 87 if (!updating) { 85 88 if (timer) 86 89 clearTimeout(timer); … … 91 94 return true; 92 95 } 93 96 94 var values = form.serializeArray();95 97 // See #11510 96 98 return inputs.bind('input cut paste keydown keypress change blur', 97 99 trigger);
Change History (3)
by , 4 years ago
Attachment: | Screen Shot 2020-05-16 at 15.03.45.jpg added |
---|
by , 4 years ago
Attachment: | Screen Shot 2020-05-16 at 15.06.43.jpg added |
---|
by , 4 years ago
Attachment: | Screen Shot 2020-05-16 at 15.15.19.jpg added |
---|