From cbf15b25f227140dbc868635cf9ceaba73e6a605 Mon Sep 17 00:00:00 2001 From: "Kenneth G. Franqueiro" Date: Fri, 15 Mar 2013 18:03:28 -0400 Subject: [PATCH] Fix #494: make Keyboard more resilient against structure resets --- CHANGES.md | 2 ++ Keyboard.js | 11 +++++++++-- test/Keyboard.html | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 13253ccf9..051eab018 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -62,6 +62,8 @@ This document outlines changes since 0.3.0. For older changelogs, see the appropriately if the footer node is present. (#463) * The `CellSelection` mixin now properly deselects if an unselected cell within the same row as a selected cell is right-clicked. +* Fixed issues with the `Keyboard` mixin pertaining to resetting columns, or + not setting them initially. (#494) * The `Keyboard` mixin now ensures that if the header area is scrolled due to a focus shift, the body scrolls with it. (#474) diff --git a/Keyboard.js b/Keyboard.js index 3538fde3b..96fe5d608 100644 --- a/Keyboard.js +++ b/Keyboard.js @@ -79,10 +79,17 @@ var Keyboard = declare(null, { isHeader = areaNode === grid.headerNode, initialNode = areaNode; - if(isHeader){ + function initHeader(){ grid._focusedHeaderNode = initialNode = cellNavigation ? grid.headerNode.getElementsByTagName("th")[0] : grid.headerNode; - initialNode.tabIndex = grid.tabIndex; + if(initialNode){ initialNode.tabIndex = grid.tabIndex; } + } + + if(isHeader){ + // Initialize header now (since it's already been rendered), + // and aspect after future renderHeader calls to reset focus. + initHeader(); + aspect.after(grid, "renderHeader", initHeader, true); }else{ aspect.after(grid, "renderArray", function(ret){ // summary: diff --git a/test/Keyboard.html b/test/Keyboard.html index 4f25ede24..b68b17cb4 100644 --- a/test/Keyboard.html +++ b/test/Keyboard.html @@ -92,6 +92,8 @@

Buttons to test programmatic focus

Focus header (no argument): +