Edgewall Software
Modify

Opened 10 years ago

Last modified 5 months ago

#11719 new defect

Auto-preview breaks TicketExt plugin, possibily others

Reported by: chris.nelson.1022@… Owned by:
Priority: high Milestone: next-major-releases
Component: ticket system Version: 1.0.1
Severity: major Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Jun Omae)

When auto-preview kicks in and new ticket content is returned via XHR, trac/ticket/templates/ticket.html uses jQuery's .replaceWith() function to update the page. This has the effect of dropping all the display: none added to the page on initial load by TicketExt.

One solution is to pass pass the XHR response through the same filters as the initial page load so the same manipulation (e.g., setting display attributes) can be applied.

Another is to change contents rather than replace the entire DOM subtree. This can be done with:

  • trac/ticket/templates/ticket.html

    diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.ht
    index 353ef63..d0865c3 100644
    a b  
    7979        $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
    8080          var items = $(reply);
    8181          // Update ticket box
    82           $("#ticket").replaceWith(items.filter('#ticket'));
     82          var newProps = $('table.properties td', items);
     83          $('#ticket table.properties td').each(function(i) {
     84            $(this).html(newProps.eq(i).html());
     85          });
     86          var newDescription = $('div.description div.searchable', items);
     87          $('#ticket div.description div.searchable').html(newDescription.html());
     88          if (items.hasClass('ticketdraft'))
     89            $('#ticket').addClass('ticketdraft');
    8390          // Unthread, unrevert and update changelog
    8491          if (!$('#trac-comments-oldest').checked())
    8592            $('#trac-comments-oldest').click().change();

though this is likely a partial fix.

(This has also been discussed at th:#11923.)

Attachments (0)

Change History (10)

comment:1 by Ryan J Ollos, 10 years ago

The issue is also seen with th:CondFieldsPlugin (th:#11920). I haven't tried to reproduce the issue with th:DynamicFieldsPlugin, but I wouldn't be surprised if it had the same issue.

I haven't dug deep into the issue, but a cursory look suggests that since the plugin's JavaScript has already been added to the page (condfields.js in the case of th:CondFieldsPlugin), we just need an event to fire after the DOM is updated by autopreview, which we could use to trigger the execution of the plugin's JavaScript.

comment:2 by Ryan J Ollos, 10 years ago

Milestone: next-dev-1.1.x

comment:3 by Jun Omae, 10 years ago

Description: modified (diff)
Milestone: next-dev-1.1.x

That patch has the following problems.

  • When summary is changed, its value wouldn't be changed in preview.
  • When status or type is changed, its value wouldn't be changed in preview.
  • When field without value is set (or value is removed from field), missing class in its header wouldn't toggle in preview.

That would make auto-preview handler more complex. I like simple.

comment:4 by Jun Omae, 10 years ago

Milestone: next-dev-1.1.x

Sorry for deleting milestone.

in reply to:  3 comment:5 by Ryan J Ollos, 10 years ago

Replying to jomae:

That patch has the following problems.

  • When summary is changed, its value wouldn't be changed in preview.
  • When status or type is changed, its value wouldn't be changed in preview.
  • When field without value is set (or value is removed from field), missing class in its header wouldn't toggle in preview.

That would make auto-preview handler more complex. I like simple.

The patch wasn't intended to be complete, or even a suitable candidate for integration, see th:comment:6:ticket:11923.

comment:6 by Ryan J Ollos, 9 years ago

Reporter: changed from Chris.Nelson@… to chris.nelson.1022@…

comment:7 by Ryan J Ollos, 9 years ago

Milestone: next-dev-1.1.xnext-dev-1.3.x

Narrowing focus for milestone:1.2. Please move ticket to milestone:1.2 if you intend to fix it.

comment:8 by christiano@…, 8 years ago

I just wanted to confirm that this problem does exist in th:DynamicFieldsPlugin

comment:9 by Ryan J Ollos, 5 years ago

Milestone: next-dev-1.3.xnext-dev-1.5.x

Milestone renamed

comment:10 by Ryan J Ollos, 5 years ago

Milestone: next-dev-1.5.xnext-major-releases

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.