You are here: Foswiki>Tasks Web>Item2638 (05 Jul 2015, GeorgeClark)Edit Attach

Item2638: Edit/Attach keyboard shortcuts not working in Firefox

Priority: Low
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Extension
Component: PatternSkin
Branches: trunk
Reported By: ChrisTracy
Waiting For:
Last Change By: GeorgeClark
The AccessKeys for Edit & Attach do not work correctly in Firefox.

This problem has been observed with Firefox 3.0.x under Windows and Firefox 3.5.x on Mac OS X. It appears to pre-date Foswiki, as I have noticed it on my older T* installations.

The accesskey for Edit & Attach is defined in two places -- on both the bottom bar and the top-right bar. If you press the attach access key repeatedly, you will notice that it cycles between the top and bottom of the page. If you press enter after hitting the access key, it follows the link. The same thing happens with the edit access key.

The authors of Firefox may have done this to allow people to still use the keyboard if, say, the webmaster has defined an accesskey twice which does two different things. In our case, both accesskeys perform the same action, it is just annoying (and non-intuitive) to have to press enter.

A quick experiment confirmed that, if I simply removed the Edit/Attach buttons on the top toolbar, the problem goes away. If you change the following line in view.pattern.tmpl, you lose the Edit/Attach buttons but now the Edit/Attach access keys work as expected:


Of course, I don't really want to lose my Edit/Attach buttons, but the current template definition did not seem to give me an easy way to preserve the Edit/Attach buttons in both places and only define the accesskey twice.

I came up with the following solution:

  • Edit templates/viewtopicactionbuttons.tmpl
  • Copy the definitions for edit_topic_link and attach_link, calling the new ones edit_topic_link_noaccesskey and attach_link_noaccesskey, and remove the accesskey definition
  • Due to the way that these templates are used, there are many other places that need to reference the new templates:
    • edit_or_create — create a new version that references edit_topic_link_noaccesskey
    • activatable_edit_or_create — create a new version that references edit_or_create_noaccesskey
    • action_activatable_edit_or_create — create a new version that references activatable_edit_or_create_noaccesskey
    • active_attach — create a new version that references attach_link_noaccesskey
    • activatable_attach — create a new version that references active_attach_noaccesskey
  • Edit templates/view.pattern.tmpl
  • Modify the top:toolbarbuttons template to reference activatable_edit_or_create_noaccesskey and activatable_attach_noaccesskey

Obviously this is not a great solution. Perhaps somebody else (who has more experience with the templates) could come up with a cleaner way of fixing this and work it into the next release? smile

Here is a diff of my changes to these two files. I have tested this with Firefox 3.0.11 running under Windows and Firefox 3.5.3 on Mac OS X.

# diff -u viewtopicactionbuttons.tmpl.orig viewtopicactionbuttons.tmpl | egrep -e "^(\+|\-)"
--- viewtopicactionbuttons.tmpl.orig    2010-01-13 08:54:56.000000000 -0800
+++ viewtopicactionbuttons.tmpl 2010-01-13 08:33:03.000000000 -0800
+%TMPL:DEF{"edit_topic_link_noaccesskey"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled" then="" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text'>&Edit"}%</a></span>%TMPL:END%
+%TMPL:DEF{"attach_link_noaccesskey"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%WEB%/%TOPIC%' rel='nofollow' %MAKETEXT{"title='Attach an image or document to this topic'>&Attach"}%</a></span>%TMPL:END%
+%TMPL:DEF{"edit_or_create_noaccesskey"}%%TMPL:P{context="new_topic" then="create_topic_link" else="edit_topic_link_noaccesskey"}%%TMPL:END%
+%TMPL:DEF{"activatable_edit_or_create_noaccesskey"}%%TMPL:P{context="inactive" then="inactive_edit_with_view_topic" else="edit_or_create_noaccesskey"}%%TMPL:END%
+%TMPL:DEF{"activatable_attach_noaccesskey"}%%TMPL:P{context="inactive" then="inactive_attach" else="active_attach_noaccesskey"}%%TMPL:END%

# diff -u view.pattern.tmpl.orig view.pattern.tmpl | egrep -e "^(\+|\-)"
--- view.pattern.tmpl.orig      2010-01-13 08:33:16.000000000 -0800
+++ view.pattern.tmpl   2010-01-13 08:33:36.000000000 -0800

Apparently there are problems in Safari with access keys not working either, See Item9038

-- PaulHarvey - 20 May 2010

This can be fixed with a local override of foswiki/templates/viewtopicactionbuttons.tmpl.

Create a new file foswiki/templates/viewtopicactionbuttons.myskin.tmpl, containing the following:

%TMPL:DEF{"edit_topic_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled" then="" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text'%IF{"context footer_text" then=" accesskey='e'" else=""}%>&Edit"}%</a></span>%TMPL:END%

%TMPL:DEF{"attach_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %MAKETEXT{"title='Attach an image or document to this topic'%IF{"context footer_text" then=" accesskey='a'" else=""}%>&Attach"}%</a></span>%TMPL:END%

Then add the following to your SitePreferences:
   * Set SKIN = myskin,pattern

With this change the access keys will only be defined for the footer links. See System.PatternSkinCustomization for more information on this type of customization.

-- DavidAllen - 30 Apr 2014

Thanks for the fix. One challenge with MAKETEXT, it can't have conditional text inside the MAKETEXT macro or the translation can't be made. The preferred way would be to make the complete MAKETEXT macro conditional. This diff applies your fix, but uses two separate MAKETEXT, one with the accesskey.

diff --git a/core/templates/viewtopicactionbuttons.tmpl b/core/templates/viewtopicactionbuttons.tmpl
index 09f2f12..ab30a40 100644
--- a/core/templates/viewtopicactionbuttons.tmpl
+++ b/core/templates/viewtopicactionbuttons.tmpl
@@ -5,14 +5,14 @@
 %TMPL:DEF{"create_topic_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%TMPL:P{context="TinyMCEPluginEnabled" else="nowysiwyg"}%' rel='nofollow' %MAKETEXT{"title='Create new topic' accesskey='c'>&Create"}%</a></span>%TMPL:END%
-%TMPL:DEF{"edit_topic_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%TMPL:P{context="TinyMCEPluginEnabled" else="nowysiwyg"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edit"}%</a></span>%TMPL:END%
+%TMPL:DEF{"edit_topic_link"}%<span class="foswikiRequiresChangePermission"> <a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%TMPL:P{context="TinyMCEPluginEnabled" else="nowysiwyg"}%' rel='nofollow' %IF{"context footer_text" then="%MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edit"}%" else="%MAKETEXT{"title='Edit this topic text' >Edit"}%" }% </a></span>%TMPL:END%
 %TMPL:DEF{"raw_edit_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%;nowysiwyg=1' rel='nofollow' %MAKETEXT{"title='Edit Wiki text' accesskey='w'>Edit &wiki text"}%</a></span>%TMPL:END%
 %TMPL:DEF{"view_topic_link"}%<span><a href='%SCRIPTURL{"view"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %MAKETEXT{"title='View topic' accesskey='v'>&View topic"}%</a></span>%TMPL:END%
-%TMPL:DEF{"attach_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%</a></span>%TMPL:END%
+%TMPL:DEF{"attach_link"}%<span class="foswikiRequiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%BASEWEB%/%BASETOPIC%' rel='nofollow' %IF{"context footer_text" then="%MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%" else="%MAKETEXT{"title='Attach an image or document to this topic'>Attach"}%" }%</a></span>%TMPL:END%
 %TMPL:DEF{"subscribe_link"}%<span>%SUBSCRIBE{format="<a href='$url' rel='nofollow' %MAKETEXT{"title='Subscribe to this topic' accesskey='s'>&Subscribe"}%</a>" formatunsubscribe="<a href='$url' rel='nofollow' %MAKETEXT{"title='Unsubscribe from this topic' accesskey='s'>Un&subscribe"}%</a>"}%</span>%TMPL:END%

-- GeorgeClark - 01 May 2014

Fix applied to Foswiki 1.2

-- Main.GeorgeClark - 01 May 2014 - 02:44

Thanks for the MAKETEXT fix.

How does the new MAKETEXT content get into the locale files for the release?

-- DavidAllen - 01 May 2014

ItemTemplate edit

Summary Edit/Attach keyboard shortcuts not working in Firefox
ReportedBy ChrisTracy
Codebase 1.0.8, trunk
SVN Range
AppliesTo Extension
Component PatternSkin
Priority Low
CurrentState Closed
Checkins distro:3bc6e4f2607f
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches trunk
trunkCheckins distro:3bc6e4f2607f
Topic revision: r8 - 05 Jul 2015, GeorgeClark - This page was cached on 25 Oct 2016 - 03:17.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License