If the cells in a DojoX grid throw an error on focus, clicking on a cell can cause the browser to scroll the grid out of view.
Steps to reproduce:
Create a new HTML file in your DojoX grid/tests directory and copy the "Test HTML File" content below into the new file. This is the test_edit.html file with the following modifications:
A tall <div> was added to the top of the body for padding.
The first cell in the ID column will throw an error when focus() is called.
Open the new test file in Chrome.
Click on the first cell in the "Id" column. It contains the number zero.
The browser will scroll up into the padding <div> and most likely scroll the grid out of view. You can click on other cells in the grid to see how it normally behaves.
When you click on a cell, _FocusManager@setFocusCell is called. That method first sets focus on a zero height/width input in a _View object. The CSS absolutely positions that input 1000 pixels above the _View domNode so focusing on it causes the browser to scroll up.
Next, setFocusCell calls _FocusManager@_focusifyCellNode(true) to focus on the cell that received the click event. _focusifyCellNode calls util.fire(n, "focus"); to set the focus on the table cell node.
Notice the call to util.fire is wrapped in a try-catch block. This suggests that errors may occur but the errors are swallowed by the do-nothing catch block. If the call to focus fails, the browser focus remains on the zero height/width input.
Two suggestions:
If the call to focus fails in _focusifyCellNode, make the code attempt to focus on some other part of the grid.
Add a call to console.error or console.warn in the catch block of _focusifyCellNode so developers are aware of any focus errors? There are other methods in _FocusManager that have smiliar empty catch blocks.
If the cells in a DojoX grid throw an error on focus, clicking on a cell can cause the browser to scroll the grid out of view.
Steps to reproduce:
grid/tests
directory and copy the "Test HTML File" content below into the new file. This is thetest_edit.html
file with the following modifications:<div>
was added to the top of the body for padding.focus()
is called.The browser will scroll up into the padding
<div>
and most likely scroll the grid out of view. You can click on other cells in the grid to see how it normally behaves.When you click on a cell,
_FocusManager@setFocusCell
is called. That method first sets focus on a zero height/width input in a_View
object. The CSS absolutely positions that input 1000 pixels above the_View
domNode so focusing on it causes the browser to scroll up.Next,
setFocusCell
calls_FocusManager@_focusifyCellNode(true)
to focus on the cell that received the click event._focusifyCellNode
callsutil.fire(n, "focus");
to set the focus on the table cell node.Notice the call to
util.fire
is wrapped in atry-catch
block. This suggests that errors may occur but the errors are swallowed by the do-nothingcatch
block. If the call tofocus
fails, the browser focus remains on the zero height/width input.Two suggestions:
focus
fails in_focusifyCellNode
, make the code attempt to focus on some other part of the grid.console.error
orconsole.warn
in thecatch
block of_focusifyCellNode
so developers are aware of any focus errors? There are other methods in_FocusManager
that have smiliar emptycatch
blocks.Test HTML File