Opened 11 years ago

Closed 11 years ago

#6989 closed defect (fixed)

[patch] [ccla] Visual indicator for focus disappears immediately after sorting.

Reported by: Joseph Scheuhammer Owned by: Nathan Toone
Priority: high Milestone: 1.3
Component: DojoX Grid Version: 1.1.1
Keywords: a11y keyboard Cc: Becky Gibson, davidb
Blocked By: Blocking:

Description

Steps to reproduce:

  1. Place focus on a cell by clicking on it. The row is highlighted, and the cell is decorated with a dashed outline focus indicator.
  2. Click a column sorter. The row is still highlighted, but the focus indicator on the cell is removed.
  3. Press the right arrow key. The focus indicator reappears on the cell just right of the cell selected at step one.

It's not clear visually where focus is after clicking the sort button in the column header. Step three implies that it was on the cell selected at step one, but is it? If so, the focus indicator should be on that cell.

Attachments (2)

6989.patch (1.7 KB) - added by Joseph Scheuhammer 11 years ago.
6989_bg.patch (2.3 KB) - added by Becky Gibson 11 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 11 years ago by Joseph Scheuhammer

Summary: Visual indicator for focus disappears immeidately after sorting.Visual indicator for focus disappears immediately after sorting.

comment:2 Changed 11 years ago by Joseph Scheuhammer

Attaching patch that partially fixes. This fix re-focuses the header that was used to invoke the sort (either by clicking on the header, or pressing space bar when focussed).

This does not work in IE6/7 the first time the column header is clicked. Thereafter it's fine.

The root of the problem is that during a sort, parts of the DOM are deleted and replaced with new markup, including the element that had focus. The patch code figures out where focus was just before the sort, and puts it back there.

Another side effect of the DOM destruction is that the scroller loses track of its position such that after a sort, the scroll position is reset to (0,0). I've filed another ticket regarding this -- see #7273.

Changed 11 years ago by Joseph Scheuhammer

Attachment: 6989.patch added

comment:3 in reply to:  2 Changed 11 years ago by Joseph Scheuhammer

Replying to clown, specifically:

This does not work in IE6/7 the first time the column header is clicked. Thereafter it's fine.

It seems that focus moves up to the document, but I can't determine why.

Steps to reproduce:

  1. Apply 6989.patch (see above).
  2. Load .../dojox/grid/tests/test_keyboard.html in IE6/7.
  3. Click a column header to invoke sort.
  4. After sort is finished, press right arrow to move focus to next column header.

The next column header will acquire focus briefly, but then focus moves to the top of the document. Pressing the TAB key next moves focus to the "dojox.grid.Grid Basic Test" heading.

comment:4 Changed 11 years ago by Adam Peller

Keywords: a11y keyboard added

comment:5 Changed 11 years ago by bill

Milestone: 1.21.3

comment:6 Changed 11 years ago by Joseph Scheuhammer

Hypothesis: this may be the result of a race condition.

  1. The sort operation is modifying the DOM.
  2. The refocus operation (in 6869.patch) is attempting to put focus back on the element that had focus before the sort.

If focus is applied before all DOM modifications are complete, then focus will be on an element that is longer present.

This may also explain #7676 and #7677 where arrowing or paging down below the viewable parts of the grid moves focus to the wrong place. Moving down in that way triggers the loading of more data, and focus may again be applied before the DOM modification is finished.

Is there a way to be notified when sorting is complete? Investigating...

comment:7 Changed 11 years ago by Nathan Toone

Owner: changed from Bryan Forbes to Nathan Toone

Reassigning to me

comment:8 Changed 11 years ago by Nathan Toone

Milestone: 1.3future

Changed 11 years ago by Becky Gibson

Attachment: 6989_bg.patch added

comment:9 Changed 11 years ago by Becky Gibson

Milestone: future1.3
Summary: Visual indicator for focus disappears immediately after sorting.[patch] [ccla] Visual indicator for focus disappears immediately after sorting.

6989_bg.patch (note this patch also contains the fix for #7676) connects to the postRender() method and set focus back to the header when that function is complete. There are still some issues - for example if you have focus on a cell in column 2, shift-tab to focus on column header 2, arrow to column header 0, press enter to sort, focus goes back to column header 2 because that is the column header that is associated with the selected cell (the cell that had focus before sorting). The grid currently doesn't remember the index of the last focused header and rather than add that behavior I can live with the quirkiness.

Also, there are some issues when the row index that was selected is no longer in the view. I think this is related to #7304 and selection following rowIndex rather than the cell. To work around this if the current rowIndex is undefined in the view, I scroll to it. It is a bit odd, but no worse than before my change where focus was completely lost after a sort and doesn't make mouse behavior any worse, either. You can see this by using the keyboard to page down until the first cell in row 33 in test_data_grid_large.html has focus, shift tab back to focus the column header, press enter to sort, data is scrolled when it is redrawn so that a selected row is visible. Try without the patch and no selected row is visible after the sort.

comment:10 Changed 11 years ago by Bryan Forbes

Resolution: fixed
Status: newclosed

(In [16816]) * Applied patches from Becky Gibson. (fixes #6989, fixes #7228, fixes #7676, fixes #7677, fixes #7914, fixes #7922, fixes #8696 !strict)

Note: See TracTickets for help on using tickets.