Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List: Support a different navigation mode where focus and selection move together #118045

Closed
joaomoreno opened this issue Mar 3, 2021 · 14 comments
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders list-widget List widget issues on-release-notes Issue/pull request mentioned in release notes verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@joaomoreno
Copy link
Member

  • When focus === selection && size 1
  • Else, navigation should only move focus
@joaomoreno joaomoreno added feature-request Request for new features or functionality list-widget List widget issues labels Mar 3, 2021
@joaomoreno joaomoreno added this to the March 2021 milestone Mar 3, 2021
@joaomoreno joaomoreno self-assigned this Mar 3, 2021
@rebornix
Copy link
Member

rebornix commented Mar 3, 2021

I found that some of the tree is already doing that, for example the Problems View, which is an ObjectTree, will move both focus and select down when arrow down key is pressed, even if we turn on multipleSelectionSupport for it.

This is because focusDown command already has a special logic for tree: pass in a fake keyboard event

tree.focusNext(count, loop, fakeKeyboardEvent);

and then openOnFocus option will decide if selection should be set to the same as focus

if (this.openOnFocus) {
this._register(Event.filter(this.widget.onDidChangeFocus, e => e.browserEvent instanceof KeyboardEvent)(e => this.onFocusFromKeyboard(e)));
}

private onFocusFromKeyboard(event: ITreeEvent<any>): void {
const focus = this.widget.getFocus();
this.widget.setSelection(focus, event.browserEvent);

The problem with this special logic is, shift+arrowdown doesn't work anymore, even with "multipleSelectionSupport": true. It will move the focus down and then move the selection down as well.


As we discussed this morning, a new flag/option will be introduced for this behavior and we should get rid of focused instanceof List || focused instanceof PagedList || focused instanceof Table checks in the list commands, and use the new option to decide what's the expected behavior. And also make sure shift+arrowdown still works.

@joaomoreno
Copy link
Member Author

joaomoreno commented Mar 10, 2021

The new selectionNavigation list/tree/table option will make selection move along with focus, when navigation commands are executed: ie UpArrow, PageUp, Home, et al.

@roblourens @sandy081 This can now be adopted in Search and Problems and you can very likely remove some annoying code you must have created to keep both focus and selection in sync.

@rebornix When adopted, can you mark as verified?

@joaomoreno joaomoreno added the verification-needed Verification of issue is requested label Mar 10, 2021
aeschli pushed a commit that referenced this issue Mar 10, 2021
@roblourens
Copy link
Member

I forgot that the openOnFocus flag exists, which opens and selects items when they become focused, so I already get this behavior. Any benefit to using both flags?

@joaomoreno
Copy link
Member Author

Oh I forgot about that, that's exactly what search, problems, etc are using. Let me see if I can clean up that one, I do look at it more as a hack, and adopt the new one instead.

@joaomoreno
Copy link
Member Author

This is now adopted in search, peek references, bulk edit, comments and markers. Thanks @roblourens for reminding me of openOnFocus. Watch out for issues. cc @jrieken @sandy081

joaomoreno added a commit that referenced this issue Mar 12, 2021
@sandy081
Copy link
Member

Thanks @joaomoreno

@roblourens
Copy link
Member

Now search doesn't open on focus anymore. Is there something else I need to do?

@joaomoreno
Copy link
Member Author

Now search doesn't open on focus anymore.

What do you mean? How can I repro?

@roblourens
Copy link
Member

roblourens commented Mar 16, 2021

Use the arrow keys to move focus around the search view tree, this is expected to fire onDidOpen

Mar-16-2021.10-52-26.mp4

@roblourens
Copy link
Member

roblourens commented Mar 16, 2021

Oh I see, this only works if there is already a selection. If there is no selection then one is not added. I am getting here by starting with focus in the search input then pressing cmd+down to move focus to the tree. Should i work around it by havingn SearchView setting a selection when this happens, or do you expect the tree to handle this?

@joaomoreno
Copy link
Member Author

I think the tree should handle it, I can fix it!

@joaomoreno joaomoreno reopened this Mar 17, 2021
@roblourens
Copy link
Member

Thanks!

@roblourens
Copy link
Member

I think this is basically the same case but test F4 navigation as well: #119199

@joaomoreno
Copy link
Member Author

joaomoreno commented Mar 24, 2021

Looking into the code, I ended up fixing it at search level. @roblourens could you maybe verify?

@roblourens roblourens added the verified Verification succeeded label Mar 25, 2021
@joaomoreno joaomoreno added the on-release-notes Issue/pull request mentioned in release notes label Mar 26, 2021
@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders list-widget List widget issues on-release-notes Issue/pull request mentioned in release notes verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants
@joaomoreno @roblourens @rebornix @sandy081 and others