From 4984078a56771a4f1be9af69eaedf8faefc2019b Mon Sep 17 00:00:00 2001 From: Thomas Bruederli <thomas@roundcube.net> Date: Tue, 03 Jun 2014 11:51:33 -0400 Subject: [PATCH] Fix list keyboard navigation with toggleselect on --- program/js/list.js | 31 ++++++++++++++++--------------- 1 files changed, 16 insertions(+), 15 deletions(-) diff --git a/program/js/list.js b/program/js/list.js index b9a437c..33693ab 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -95,6 +95,12 @@ this.tbody = this.list; } + if ($(this.list).attr('role') == 'listbox') { + this.aria_listbox = true; + if (this.multiselect) + $(this.list).attr('aria-multiselectable', 'true'); + } + if (this.tbody) { this.rows = {}; this.rowcount = 0; @@ -116,12 +122,6 @@ $(this.list).attr('tabindex', '0') .on('focus', function(e){ me.focus(e); }); } - } - - if ($(this.list).attr('role') == 'listbox') { - this.aria_listbox = true; - if (this.multiselect) - $(this.list).attr('aria-multiselectable', 'true'); } return this; @@ -897,9 +897,10 @@ */ select_row: function(id, mod_key, with_mouse) { - var select_before = this.selection.join(','); + var select_before = this.selection.join(','), + in_selection_before = this.in_selection(id); - if (!this.multiselect) + if (!this.multiselect && with_mouse) mod_key = 0; if (!this.shift_start) @@ -935,21 +936,21 @@ this.multi_selecting = true; } - // trigger event if selection changed - if (this.selection.join(',') != select_before) - this.triggerEvent('select'); - if (this.last_selected != 0 && this.rows[this.last_selected]) { $(this.rows[this.last_selected].obj).removeClass('focused') .find(this.col_tagname()).eq(this.subject_col).removeAttr('tabindex'); } // unselect if toggleselect is active and the same row was clicked again - if (this.toggleselect && this.last_selected == id) { + if (this.toggleselect && in_selection_before) { this.clear_selection(); - id = null; } - else { + // trigger event if selection changed + else if (this.selection.join(',') != select_before) { + this.triggerEvent('select'); + } + + if (this.rows[id]) { $(this.rows[id].obj).addClass('focused'); // set cursor focus to link inside selected row if (this.focused) -- Gitblit v1.9.1