Modify

Opened 4 years ago

Closed 4 years ago

#13949 closed defect (fixed)

ticket comment preview affected from JS error

Reported by: clemens Owned by: clemens
Priority: normal Component: TracKeywordsPlugin
Severity: normal Keywords: patch
Cc: Trac Release: 1.4

Description

If the TracKeywordsPlugin is running, then it can negatively affect the preview when editing a ticket comment. This preview box is missing. It is in the HTML DOM but its style is invisible. In the following picture (taken without the TracKeywordsPlugin) one can see this preview box:

screenshot of preview box when editing an existing ticket comment

I believe the root cause for this problem is a JavaScript error. In source:trackeywordsplugin/trunk/trackeywords/htdocs/trac_keywords.js@17396#L39 the result of getElementById() is not checked against null.

document.getElementById(field_id)

In fact it can be null in case somebody is attempting to edit a ticket comment. (It is rare, but it happens.) The special thing about this is that in such situation TRAC will remove the normal "Ticket Property" box and thus also removes the "keyword" ticket field (field-keywords) which TracKeywordsPlugin is looking for.

One shall check the result validity when calling getElementById()!

I cannot explain exactly how this JavaScript error affects the the preview box and makes its style invisible. I would guess that being invisible is the default of those preview boxes. Other JavaScript code is somehow affected. Eventually the box remains invisible, even in cases when it shall be displayed.

I have a patch to offer which simply checks the result of getElementById() and avoids this error: attachment:"trac_keywords_2021-01-29.js.diff"

Attachments (2)

2021-01-29-trac-edit-comment.png (167.2 KB) - added by clemens 4 years ago.
screenshot of preview box when editing an existing ticket comment
trac_keywords_2021-01-29.js.diff (1.5 KB) - added by clemens 4 years ago.
patch file to check result of getElementById

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by clemens

screenshot of preview box when editing an existing ticket comment

Changed 4 years ago by clemens

patch file to check result of getElementById

comment:1 Changed 4 years ago by Ryan J Ollos

Owner: set to clemens
Status: newassigned

comment:2 Changed 4 years ago by clemens

Resolution: fixed
Status: assignedclosed

In 17980:

One shall check the result validity when calling getElementById()!

fixes #13949

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain clemens.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.