Opened 12 years ago
Closed 11 years ago
#9296 closed defect (fixed)
Tree: throws "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus." when nodes have a margin
Reported by: | Phil DeJarnett | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Dijit | Version: | 1.3.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description (last modified by )
I don't have an easy test case, but I know how to fix it: If you:
- Have a rootless tree, and
- You style the nodes to use margins for spacing, and
- A user clicks in the margin,
The tree attempts to focus on the rootNode. Since this node is not actually visible (1), but isTreeNode is true, the tree attempts focus.
The solution is to modify _onClick and _onDblClick to ignore the rootNode when the rootNode is hidden.
Again, this is only a problem if margins are used to space out nodes. For example, I have a horizontal line separating two sections, and I create it by setting a top border, top padding, and top margin on the node. It's easy to click that space and that's what throws the error.
Attachments (1)
Change History (5)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | General → Dijit |
---|---|
Description: | modified (diff) |
Owner: | anonymous deleted |
Summary: | dijit.Tree throws "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus." when nodes have a margin → Tree: throws "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus." when nodes have a margin |
Hmm, I think I need a test case before checking in a fix.
Changed 11 years ago by
Attachment: | test_Tree.html added |
---|
margin added to tree nodes; clicking near the nodes in the second tree makes them all disappear
comment:3 Changed 11 years ago by
Milestone: | tbd → 1.4 |
---|---|
Owner: | set to bill |
Status: | new → assigned |
OK, I tried a test and reproduced the problem... it's from the _onClick handler on Tree itself (Tree is trying to be clever by only having a single click handler for the entire tree), which does:
var domElement = e.target; var nodeWidget = dijit.getEnclosingWidget(domElement);
As you've pointed out that doesn't work well. The handler should really be on the row node.
Same story for onDblClick.
I'll fix it now.
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Update: I tried hacking in a solution that stopped the checks on rootNode - then the error just migrated to a different node.
Instead, I think a better solution is to wrap focusNode in a try/catch block:
This resolved the issue (even if it feels hacky) for me under IE.