Opened 5 years ago
Last modified 14 months ago
#13235 new defect
Comment textarea doesn't get focus on loading when replying using Firefox and Edge
Reported by: | Jun Omae | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-stable-1.6.x |
Component: | rendering | Version: | 1.0.19 |
Severity: | minor | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
We expect comment textarea gets focus when visiting https://trac.edgewall.org/demo-1.0/ticket/1?replyto=description#comment, however it doesn't work using Firefox and Edge. It works fine using Chrome.
Attachments (0)
Change History (6)
comment:1 by , 5 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
In 1.2-stable, comment textarea gets focus when replying. trac-autofocus
is used in class attribute of comment textare after [14393] (#11835 but not described).
Backport:
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html index 057b64a38..d27dbbda1 100644
a b 205 205 <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> 206 206 here. 207 207 </label> 208 <textarea id="comment" name="comment" class=" wikitext trac-fullwidth trac-resizable" rows="10" cols="78">208 <textarea id="comment" name="comment" class="${classes('wikitext', 'trac-fullwidth', 'trac-resizable', 'trac-autofocus' if replyto else None)}" rows="10" cols="78"> 209 209 ${comment}</textarea> 210 210 </fieldset> 211 211 </div>
comment:3 by , 4 years ago
comment:4 by , 4 years ago
I noticed comment editor has the same issue but the issue also has been fixed in 1.2-stable.
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html index 92da3677c..56e28e861 100644
a b 205 205 <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> 206 206 here. 207 207 </label> 208 <textarea id="comment" name="comment" class=" wikitext trac-fullwidth trac-resizable" rows="10" cols="78">208 <textarea id="comment" name="comment" class="${classes('wikitext', 'trac-fullwidth', 'trac-resizable', 'trac-autofocus' if replyto else None)}" rows="10" cols="78"> 209 209 ${comment}</textarea> 210 210 </fieldset> 211 211 </div> -
trac/ticket/templates/ticket_change.html
diff --git a/trac/ticket/templates/ticket_change.html b/trac/ticket/templates/ticket_change.html index 662384b4b..db228d322 100644
a b Arguments: 116 116 <form py:if="show_editor" id="trac-comment-editor" method="post" 117 117 action="${href.ticket(ticket.id) + '#comment:%d' % cnum}"> 118 118 <div> 119 <textarea name="edited_comment" class="wikitext trac-fullwidth trac-resizable " rows="10" cols="78">119 <textarea name="edited_comment" class="wikitext trac-fullwidth trac-resizable trac-autofocus" rows="10" cols="78"> 120 120 ${edited_comment if edited_comment is not None else change.comment}</textarea> 121 121 <input type="hidden" name="cnum_edit" value="${cnum}"/> 122 122 </div>
The patch would fix the issue on both reply and edit with Firefox in my environment but the issue on edit with Chrome is not fixed.
Hmm, I think it seems focusing by anchor (e.g. #comment
, #comment:N
) and trac-autofocus
are conflicting. By the conflicting, textarea may not be focused.
comment:5 by , 4 years ago
Milestone: | 1.0.20 → next-stable-1.4.x |
---|---|
Owner: | removed |
Severity: | normal → minor |
Status: | assigned → new |
Additional changes would make fine on both Firefox and Chrome but edit doesn't focus textarea for edit-comment on Edge. I cannot find perfect solution. Re-targeting to next-stable-1.4. That is a minor issue….
-
trac/templates/layout.html
diff --git a/trac/templates/layout.html b/trac/templates/layout.html index 25ea9ff67..9f6074d1a 100644
a b 57 57 return false; 58 58 }); 59 59 </py:if> 60 $(".trac-autofocus").focus(); 60 var autofocus = $(".trac-autofocus"); 61 if (autofocus.length !== 0) { 62 if (location.hash) 63 setTimeout(function() { autofocus.focus() }, 1); 64 else 65 autofocus.focus(); 66 } 61 67 $(".trac-target-new").attr("target", "_blank"); 62 68 setTimeout(function() { $(".trac-scroll").scrollToTop() }, 1); 63 69 $(".trac-disable-on-submit").disableOnSubmit();
Work around is to focus it when the given element in the hash is input element:
trac/templates/layout.html