Closed Bug 984980 Opened 11 years ago Closed 6 years ago

Keyboard shortcut to switch between preview mode and edit mode

Categories

(Bugzilla :: Bugzilla-General, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 6.0

People

(Reporter: rik, Unassigned)

Details

Attachments

(1 file, 3 obsolete files)

Github uses Cmd-Shift-P on Mac to do that and it's pretty neat.
Assignee: nobody → general
Component: Sandstone/Mozilla Skin → Bugzilla-General
Product: bugzilla.mozilla.org → Bugzilla
QA Contact: default-qa
Version: Production → unspecified
Severity: normal → enhancement
Assignee: general → acho.arnold
Target Milestone: --- → Bugzilla 5.0
Attached patch Patch for bug 984980 (obsolete) — Splinter Review
This patch uses the keyboard shortcut Ctrl + Shift + P to switch between preview mode and edit mode when writing comments
Attachment #8396636 - Flags: review?(gerv)
Comment on attachment 8396636 [details] [diff] [review]
Patch for bug 984980

I'm fairly sure I remember reading that the a11y team said not to use aria roles for doing things like this. Surely there's a better way to detect whether we are previewing or not?

glob: any issues with us watching every key event on these pages?

Gerv
Attachment #8396636 - Flags: review?(gerv) → review-
It would be nice to use Cmd-Shift-P on Mac instead of Ctrl-Shift-P.
>I'm fairly sure I remember reading that the a11y team said not to use aria roles for doing things like this

Okey I didn't know about that fact

>It would be nice to use Cmd-Shift-P on Mac instead of Ctrl-Shift-P.
I'm sorry I only have access to a linux computer at the moment so I can't test Cmd on Mac. I would be very grateful if you could give me the keycode of Cmd on Mac
Cmd is 224.
Attached patch Updated patch for bug 984980 (obsolete) — Splinter Review
This patch checks whether we are previewing or not without using aria

It also enables Cmd-Shift-P to be used on Mac.
Attachment #8396636 - Attachment is obsolete: true
Attachment #8399149 - Flags: review?(gerv)
Attached patch Updated patch for bug 984980 (obsolete) — Splinter Review
This patch checks whether we are previewing or not without using aria

It also enables Cmd-Shift-P to be used on Mac.
Attachment #8399149 - Attachment is obsolete: true
Attachment #8399149 - Flags: review?(gerv)
Attachment #8399150 - Flags: review?(gerv)
Comment on attachment 8399150 [details] [diff] [review]
Updated patch for bug 984980

r=gerv. We should get someone with a Mac to test it once it is checked in.

Gerv
Attachment #8399150 - Flags: review?(gerv) → review+
Comment on attachment 8399150 [details] [diff] [review]
Updated patch for bug 984980

Review of attachment 8399150 [details] [diff] [review]:
-----------------------------------------------------------------

there's some minor few style issues with this patch that i'd like to see addressed first.

::: js/field.js
@@ +1089,5 @@
> +    // Store an entry for every key pressed
> +    keys[e.keyCode] = true;
> +
> +    // (Ctrl XOR cmd) + Shift + P
> +    if ( (!keys[17] != !keys[224]) && keys[16] && keys[80]) {

remove space between ( (

@@ +1092,5 @@
> +    // (Ctrl XOR cmd) + Shift + P
> +    if ( (!keys[17] != !keys[224]) && keys[16] && keys[80]) {
> +        // Check if we are already in preview mode
> +        var Dom = YAHOO.util.Dom;
> +        if (Dom.hasClass('comment_preview_tab', 'active_comment_tab')){

you're only referencing Dom once, there's no need to create a variable for it

@@ +1098,5 @@
> +            document.getElementById('comment').focus();
> +            YAHOO.util.Event.preventDefault(e);
> +        }
> +
> +        else{

need a space after else

::: template/en/default/attachment/create.html.tmpl
@@ +14,5 @@
> +[% javascript = BLOCK %]
> +  YAHOO.util.Event.onDOMReady(function() {
> +    YAHOO.util.Event.addListener(window, 'keydown', keys_pressed, [% bug.id FILTER none %]);
> +    YAHOO.util.Event.addListener(window, 'keyup', keys_released);
> +    });

this line is indented one level too much
Attachment #8399150 - Flags: review-
This patch solves the issues raised by glob in comment 9 above
Attachment #8399150 - Attachment is obsolete: true
Attachment #8401683 - Flags: review?(glob)
Attachment #8401683 - Flags: review?(glob) → review?(gerv)
Comment on attachment 8401683 [details] [diff] [review]
A revision of my previous patch for Bug 984980

r=gerv.

Gerv
Attachment #8401683 - Flags: review?(gerv) → review+
Flags: approval?
I guess this gives us a framework for doing more stuff with keys in the future, too.

My only question on this is should we do something to make this discoverable?  It looks nice but it only works if you know about it.
Flags: approval? → approval+
Counting objects: 21, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.57 KiB | 0 bytes/s, done.
Total 11 (delta 8), reused 0 (delta 0)
To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   23bad39..08f83a7  master -> master

Thanks, Acho!

Gerv
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
\o/

If you can point me to a Bugzilla instance with that patch, I can do the Mac test.
The patch contained tabs, making Tinderbox to turn orange.

To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   08f83a7..b639a1a  master -> master
Comment on attachment 8401683 [details] [diff] [review]
A revision of my previous patch for Bug 984980

>diff --git a/template/en/default/bug/show-header.html.tmpl b/template/en/default/bug/show-header.html.tmpl

>++[% javascript = BLOCK %]

The extra + before [% javascript = BLOCK %] makes + to be displayed before <!DOCTYPE html>, which breaks the rendering of HMTL pages. Has this patch been tested??


+        YAHOO.util.Event.onDOMReady(function() {
+            YAHOO.util.Event.addListener(window, 'keydown', keys_pressed, [% bug.id FILTER none %]);
+            YAHOO.util.Event.addListener(window, 'keyup', keys_released);
+        });
+[% END %]

The indentation is wrong. Templates use 2 whitespaces, neither 4 nor 8.


To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   536c249..ae77f29  master -> master
This broke URL rewrites apparently, need to back it out for now (we just released with this in it and now have a broken release :( about to re-roll for unrelated reasons (wasn't the only regression) and the release will be easier without this, we can fix it and put it back after the release is re-rolled.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Patch backed out.

To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   ae77f29..406dcbb  master -> master
Flags: approval+
Comment on attachment 8401683 [details] [diff] [review]
A revision of my previous patch for Bug 984980

See comments 15-17: 3 regressions in a single patch!
Attachment #8401683 - Flags: review-
:-(

I tested an earlier version but not the very latest one, as I understood it to be only fixing the "minor style issues" from comment 9. :-| So that's how I missed the extra "+". bePolite: can you tell us how you didn't spot that problem?

My editor (geany) has very un-useful "show white space" (puts tiny dots in all whitespace) and "show line endings" (ugly "CR" or "LF" black text) options, but not the far more useful "show tab characters, plus any whitespace at end of lines" option that I'd like to see. :-( So I don't have an easy way of detecting patches with tabs. Is it required that reviewers run the tests with all patches they review, or do we expect the patch author to have done that?

Gerv
(In reply to Gervase Markham [:gerv] from comment #20)
> an easy way of detecting patches with tabs. Is it required that reviewers
> run the tests with all patches they review, or do we expect the patch author
> to have done that?

The reviewer is supposed to run tests, especially with new contributors who probably don't even know that these tests exist.
(In reply to Gervase Markham [:gerv] from comment #20)
> bePolite: can you tell us how you didn't spot that
> problem?

It seems i was just focused on solving the problem addressed by this bug that I didn't notice the side effects of my patch.

I noticed the broken URL rewrites later but I also had no Idea that it was related to the javascript changes in my patch.

I will endevour to be much more careful next time
Status: REOPENED → ASSIGNED
Target Milestone: Bugzilla 5.0 → ---
Assignee: arnold → general
Status: ASSIGNED → NEW

Bugzilla 6.0 will ship with the new modal UI created for BMO, which offers the keyboard shortcut.

Status: NEW → RESOLVED
Closed: 11 years ago6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Bugzilla 6.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: