Bug 436703 - [IDE] Open resource dialog go back to search input field on pressing up on the top list element
Summary: [IDE] Open resource dialog go back to search input field on pressing up on th...
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Robert Roth CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, greatfix, helpwanted
Depends on:
Blocks:
 
Reported: 2014-06-05 08:57 EDT by Gabor Gyimesi CLA
Modified: 2015-04-22 06:39 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Gyimesi CLA 2014-06-05 08:57:28 EDT
In the "open resource" dialog when you press down arrow on the keyboard, the focus jumps down to the list of the results. It doesn't works in the oppoiste direction.
It would be great if the cursor is standing on the first list element(upper one) the focus would go back to the input field on pressing up arrow on the keyboard.
Comment 1 Robert Roth CLA 2015-04-21 20:09:58 EDT
I would like to work on this in context of the #greatfix initiative, so anyone, please add the greatfix keyword and assign me.
While investigating this, I have found that
* the code to do this already exists since at least 2006 [1](actually from earlier, but the file got renamed/refactored/moved several time and there's no real value of tracking it further) - it handles SWT.ARROW_UP in the table in case the selection has only one item and that's the first one, it jumps back to the filter widget.
* the fix for bug 178375 [2] contains a typo, while trying to make sure "if not using multiselect with ctrl+shift+arrow" it actually checks "if using UP AND Ctrl AND Shift", which got found only after the thing got released and verified, and the mistake is pointer out by the committer [3]
The fix is a fairly trivial one, changing only two not equal signs (the one checking the Ctrl and Shift flags) to equals.

[1] http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.java?h=R3_8_maintenance&id=570778ee8c5319618f94d7bf75706a01ccb6bb20
[2] http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/dialogs/FilteredItemsSelectionDialog.java?h=R3_8_maintenance&id=c5a3e8729b09f11f55264089d2258d455b7d88d3
[3] https://bugs.eclipse.org/bugs/show_bug.cgi?id=178375#c12
Comment 2 Eclipse Genie CLA 2015-04-21 20:10:37 EDT
New Gerrit change created: https://git.eclipse.org/r/46218
Comment 3 Brian de Alwis CLA 2015-04-21 21:35:34 EDT
Very very nice find, Robert!  I've meant to dig into this myself.

I wonder if this shouldn't be testing 

	(e.stateMask & SWT.MODIFIER_MASK) == 0

instead.  Otherwise UP and DOWN will still work with ALT or COMMAND (on OS X).
Comment 4 Robert Roth CLA 2015-04-21 22:14:17 EDT
(In reply to Brian de Alwis from comment #3)
> Very very nice find, Robert!  I've meant to dig into this myself.
> 
> I wonder if this shouldn't be testing 
> 
> 	(e.stateMask & SWT.MODIFIER_MASK) == 0
> 
> instead.  Otherwise UP and DOWN will still work with ALT or COMMAND (on OS
> X).

You're right, it probably doesn't make any sense to assume that somebody would like to use ALT+UP or COMMAND+UP to jump back to the filter box, while he's using DOWN to jump down to the table. I'm updating the patch-set with this change.
Comment 5 Brian de Alwis CLA 2015-04-21 22:36:48 EDT
I've discovered that it's a bit more involved: there's logic there to prevent selecting the ItemsListSeparator, but it doesn't prevent in a multiselect case.  The code also presumes that multiselection is a combination of CTRL + SHIFT, which is not be true of all platforms.

It seems to me that the right logic here is:

  if(key == ARROW_UP) {
    if((stateMask & MODIFIER_MASK) == 0 && selectedIndex <= 0 && selectionCount <= 1) {
       pattern.setFocus();
    } else if(table.elementAt(selectedIndex) instanceof ItemsListSeparator) {
       table.deselect(selectedIndex);
       table.select(selectedIndex - 1);  // select the object above
    }
  } else if(key == ARROW_DOWN) {
     if(table.elementAt(selectedIndex) instanceof ItemsListSeparator) {
       table.deselect(selectedIndex);
       table.select(selectedIndex + 1);  // select the object below
    }
  }
Comment 6 Brian de Alwis CLA 2015-04-21 23:31:45 EDT
I can't actually get the ARROW_DOWN case to work properly.  It seems strange to have logic that can only avoid selecting the ItemListSeparator under certain circumstances.

And since the dialog properly handles when the ItemListSeparator is selected, I'm inclined to replace the ARROW_UP with the following and remove the ARROW_DOWN case entirely:

	if (e.keyCode == SWT.ARROW_UP && (e.stateMask & SWT.MODIFIER_MASK) == 0
			&& list.getTable().getSelectionIndex() <= 0 && list.getTable().getSelectionCount() <= 1) {
		// If we're at the top then shift focus back to the pattern.
		// Set the selection to the first element in case the user
		// unselected all elements, otherwise the selection may wrap
		// to the last object which is disconcerting
		list.getTable().setSelection(0);
		pattern.setFocus();
	}

This seems to behave predictably on OS X.
Comment 7 Robert Roth CLA 2015-04-22 01:43:07 EDT
(In reply to Brian de Alwis from comment #6)
> I can't actually get the ARROW_DOWN case to work properly.  It seems strange
> to have logic that can only avoid selecting the ItemListSeparator under
> certain circumstances.
> 
> And since the dialog properly handles when the ItemListSeparator is
> selected, I'm inclined to replace the ARROW_UP with the following and remove
> the ARROW_DOWN case entirely:
> 
> 	if (e.keyCode == SWT.ARROW_UP && (e.stateMask & SWT.MODIFIER_MASK) == 0
> 			&& list.getTable().getSelectionIndex() <= 0 &&
> list.getTable().getSelectionCount() <= 1) {
> 		// If we're at the top then shift focus back to the pattern.
> 		// Set the selection to the first element in case the user
> 		// unselected all elements, otherwise the selection may wrap
> 		// to the last object which is disconcerting
> 		list.getTable().setSelection(0);
> 		pattern.setFocus();
> 	}
> 
> This seems to behave predictably on OS X.

I like this better than the previous one, as that's not too easy to implement, I've spent some hours to do that.  This solution behaves predictably on Linux+GTK too, maybe someone confirming this on Windows would be nice, but as Windows uses the same modifiers as Linux, I guess we should be fine.
I will update the gerrit request with this proposal. Thanks for looking into this.
Comment 8 Dani Megert CLA 2015-04-22 05:43:40 EDT
I'd like to defer this to 4.6.
Comment 9 Robert Roth CLA 2015-04-22 06:07:09 EDT
Updating target based on comment 8.
Comment 10 Dani Megert CLA 2015-04-22 06:32:56 EDT
I looked at this a bit closer. We should not fix this as this would result in an inconsistent UI. The same pattern is applied all over the IDE i.e. moving down from a search field goes into the list and moving up stops at the first element.

You e.g. see this in several preference pages or views.

Sorry Robert.
Comment 11 Robert Roth CLA 2015-04-22 06:39:19 EDT
(In reply to Dani Megert from comment #10)
> I looked at this a bit closer. We should not fix this as this would result
> in an inconsistent UI. The same pattern is applied all over the IDE i.e.
> moving down from a search field goes into the list and moving up stops at
> the first element.
> 
> You e.g. see this in several preference pages or views.
> 
> Sorry Robert.

Don't worry, this is your call after all.
However, I completely agree with the reporter that even if this is consistently like this everywhere in eclipse, it doesn't make much sense to have the down arrow change component, but up arrow not doing the opposite.
Too bad that this won't get fixed, this is a really great a11y feature, pressing up arrow is sooo much easier then pressing Shift+Tab.

I guess after this decision you can remove the relevant code, as it's clear that the modifier handling is broken there.