From 336324dac1bb231c797ec1dd499f59e779357d0f Mon Sep 17 00:00:00 2001 From: Jeff Arnold Date: Fri, 2 Aug 2013 13:25:20 -0400 Subject: [PATCH] Make tab code handle the case that >1 msgs are being edited (imported from commit b385c0d67ed1fe6363cdff0c39eb395399f04667) --- static/js/hotkey.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/static/js/hotkey.js b/static/js/hotkey.js index 13a1bb8c19..893ad39776 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -102,7 +102,7 @@ function get_event_name(e) { // // Returns true if we handled it, false if the browser should. function process_hotkey(e) { - var row; + var row, focused_message_edit_content, focused_message_edit_save, message_edit_form; // Disable hotkeys on settings page etc., and when a modal pop-up // is visible. @@ -137,11 +137,17 @@ function process_hotkey(e) { // In Safari and the desktop app, we can't tab to buttons. Intercept the // tab from the message edit content box to Save and then Cancel. if (event_name === "tab") { - if ($("#message_edit_content").is(":focus")) { - $(".message_edit_save").focus(); + focused_message_edit_content = $(".message_edit_content").filter(":focus"); + if (focused_message_edit_content.length > 0) { + message_edit_form = focused_message_edit_content.closest(".message_edit_form"); + message_edit_form.find(".message_edit_save").focus(); return true; - } else if ($(".message_edit_save").is(":focus")) { - $(".message_edit_cancel").focus(); + } + + focused_message_edit_save = $(".message_edit_save").filter(":focus"); + if (focused_message_edit_save.length > 0) { + message_edit_form = focused_message_edit_save.closest(".message_edit_form"); + message_edit_form.find(".message_edit_cancel").focus(); return true; } }