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:
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)
Change History (4)
Changed 4 years ago by
Attachment: | 2021-01-29-trac-edit-comment.png added |
---|
Changed 4 years ago by
Attachment: | trac_keywords_2021-01-29.js.diff added |
---|
patch file to check result of getElementById
comment:1 Changed 4 years ago by
Owner: | set to clemens |
---|---|
Status: | new → assigned |
screenshot of preview box when editing an existing ticket comment