Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 466780

Summary: Selection in navigation tree does not invoke an action (must click on the link text rather than the just the row)
Product: [ECD] Orion Reporter: Steve Northover <steve_northover>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: curtis.windatt.public, libingw, mamacdon, Silenio_Quarti
Version: unspecified   
Target Milestone: 9.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Steve Northover CLA 2015-05-07 16:42:06 EDT
1) Open the Orion editor on a directory with more than one file
2) Select the first file by clicking on the link text (the file opens)
3) Select the second file by clicking on the row (ie. not on the link)
4) BUG: The selection moves to the new row, but the second file is not opened

Background:

I understand that the selection model in Orion is consistent and it has been explained to me in the past how it works.  Selection does not perform an action.  In order to perform an action, you must click on the link.  This allows you to select many items, then perform a popup or file menu item on the selected items without invoking the action (for example, loading a file from the server which may be a slow operation).

The problem with this behavior is that it does not match other UI's on the web.  For example, in other web UI's you can select anywhere on an item (not just the link) and the action happens.  Having Orion be different means that people think Orion has a bug (I know I did months ago when I first started playing with the technology).

The attached patch that causes the link action to fire when the mouse is pressed anywhere in a tree item.  The tree is used many places in Orion and these places need to be tested should we decide to go ahead with the patch.  It would also be possible to add this behavior as a preference that could be turned on or off (default on) but this might be overkill.
Comment 1 Steve Northover CLA 2015-05-07 16:42:20 EDT
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js
index 7381319..d8f126f 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js
@@ -192,6 +192,17 @@
             });
             
         this._clickListener = function(evt) {
+            if (!(evt.metaKey || evt.altKey || evt.shiftKey || evt.ctrlKey)) {
+                var navHandler = _self.getNavHandler();
+                if (navHandler && navHandler.getSelectionPolicy() !== "cursorOnly") {
+                    var link = lib.$("a", evt.target);
+                    if (link) {
+                        // Run the link action when user clicks anywhere in the item cell
+//                        link.click();
+                        window.location.href = link.href;
+                    }
+                }
+            }
             if (evt.target.tagName === "A") { //$NON-NLS-0$
                 var temp = evt.target;
                 while (temp) {
Comment 2 Mark Macdonald CLA 2015-05-08 09:33:02 EDT
This means that row selection only works when you hold down a modifier key. So effectively there is no way to highlight an item (for deletion, renaming, etc) with a touch device -- you will always open it instead.

So perhaps lists that support row selection should provide a generic "selection mode" toggle that would allow actions to be taken on the row without following links. I know some mobile apps provide this. (This means we're almost back at the very early Orion UI, which had a checkbox on every list item!)
Comment 3 Steve Northover CLA 2015-05-08 09:53:52 EDT
Is seems to me that you will still be able to select, but the behavior will be that something opens when before it did not.  I am likely missing something. 

Can you give me some exact steps that will fail on my touch device?  I can try it out with the patch.
Comment 4 Mark Macdonald CLA 2015-05-08 14:31:26 EDT
(In reply to Steve Northover from comment #3)
> Is seems to me that you will still be able to select, but the behavior will
> be that something opens when before it did not.  I am likely missing
> something. 
> 
> Can you give me some exact steps that will fail on my touch device?  I can
> try it out with the patch.

I see your point. You can still take the action, but it requires opening the file first as a side effect.
Comment 5 Steve Northover CLA 2015-06-05 18:05:56 EDT
Silenio, this one is really bad for me.  No other editor that I am using has this behavior including some of the ones I have tried on the desktop.  Each time I hit it, I think that Orion is broken and has not fetched the contents of my file.
Comment 6 libing wang CLA 2015-06-24 14:44:08 EDT
Talked to Silenio today and we think we should fix it now. More and more people complained about this.
As the selection model is generic to all pages, I will tried to test all the corner cases to see if other selection stories are broken after the changes I will make.
Working on it now...
Comment 7 libing wang CLA 2015-06-24 17:13:53 EDT
I've changed the patch a little bit and tested on my self hosting.
Here is the new patch.
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js
index a414da3..2695e61 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorer-table.js
@@ -192,18 +192,18 @@
 			});
 			
 		this._clickListener = function(evt) {
-			if (evt.target.tagName === "A") { //$NON-NLS-0$
-				var temp = evt.target;
-				while (temp) {
-					if (temp._item) {
-						break;
-					}
-					temp = temp.parentNode;
-				}
-				if (temp && temp._item) {
-					_self.onLinkClick({type: "linkClick", item: temp._item}); //$NON-NLS-0$
-				}
-			}
+            if (!(evt.metaKey || evt.altKey || evt.shiftKey || evt.ctrlKey)) {
+                var navHandler = _self.getNavHandler();
+                if (navHandler && navHandler.getSelectionPolicy() !== "cursorOnly") {
+                    var link = lib.$("a", evt.target);
+                    if (link) {
+            			window.location.href = link.href;
+            			_self._clickLink(link);
+            			return;
+                    }
+                }
+            }
+            _self._clickLink(evt.target);
 		};
 		var parent = lib.node(this.parentId);
 		if (parent) {
@@ -226,6 +226,20 @@
 			}
 			mExplorer.Explorer.prototype.destroy.call(this);
 		},
+		_clickLink: function(linkElement) {
+			if (linkElement.tagName === "A") { //$NON-NLS-0$
+				var temp = linkElement;
+				while (temp) {
+					if (temp._item) {
+						break;
+					}
+					temp = temp.parentNode;
+				}
+				if (temp && temp._item) {
+					this.onLinkClick({type: "linkClick", item: temp._item}); //$NON-NLS-0$
+				}
+			}
+		},
 		onLinkClick: function(clickEvent) {
 			this.dispatchEvent(clickEvent);
 		},
Comment 8 libing wang CLA 2015-06-24 17:23:49 EDT
I've tested on both editor page and git page.
We will lose multiple selection on tablets because there is no SHIFT and CTRL keys in tablets. Before the change, user can
1. Tap on the empty space to select a item
2. Tap on another item to do multiple selection
3. Tap on a selected item to deselect.

Also found another thing for keyboard users when they just use up and down arrow keys to move the selection. This is not related to the change I've made because it only changed the click behavior:
If you move the selection by arrow keys, it does not open that file unless you press enter key. If a user depends on left hand selection to see which file is being opened, this case is a bit confusing. But again, this is an existing issue.
Comment 9 Steve Northover CLA 2015-06-26 13:38:58 EDT
For now, I would detect that we are on a tablet (or don't have a keyboard) and run the old code.

I'm not sure what the error you describe in the keyboard flow is but it seems as if it exists regardless of this change.
Comment 10 libing wang CLA 2015-06-26 15:02:20 EDT
Fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=bc02d92bbd3e927831d870753c932c790bb9ff16.

We are losing the multiple selection on IPAD now but we can address it in another bug if we need to.
We need some agressive tests on beta3 on Monday for this fix though I've tested a lot on Orion.
Comment 11 Steve Northover CLA 2015-06-26 15:15:24 EDT
This might have been an excellent thing to dark launch behind a flag so that it could be turned on or off easily.  More discussion of this next week.