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

Set a max-height on comments and add vertical scrolling (#174629) #180044

Merged
merged 4 commits into from Apr 20, 2023

Conversation

gjsjohnmurray
Copy link
Contributor

This PR implements #174629, setting a maximum visible height of comments, after which a vertical scrollbar will appear.

@gjsjohnmurray
Copy link
Contributor Author

/assign @alexr00

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, it works great! Can the arrow keys be used to control scroll when the comment is focused?

src/vs/workbench/contrib/comments/browser/commentNode.ts Outdated Show resolved Hide resolved
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@alexr00 alexr00 enabled auto-merge (squash) April 19, 2023 15:46
@alexr00 alexr00 added this to the April 2023 milestone Apr 19, 2023
@gjsjohnmurray
Copy link
Contributor Author

Can the arrow keys be used to control scroll when the comment is focused

@alexr00 I'm willing to take a shot at this if you'd like it before merging. I didn't find any sign of your horizontal scroll implementation supporting it though, so I don't have a model to copy.

@gjsjohnmurray
Copy link
Contributor Author

Currently, once the user has focused on a comment in a thread the arrow keys navigate to the next or previous comment in the thread:

this._register(dom.addDisposableListener(this._commentsElement, dom.EventType.KEY_DOWN, (e) => {
const event = new StandardKeyboardEvent(e as KeyboardEvent);
if (event.equals(KeyCode.UpArrow) || event.equals(KeyCode.DownArrow)) {
const moveFocusWithinBounds = (change: number): number => {
if (this._focusedComment === undefined && change >= 0) { return 0; }
if (this._focusedComment === undefined && change < 0) { return this._commentElements.length - 1; }
const newIndex = this._focusedComment! + change;
return Math.min(Math.max(0, newIndex), this._commentElements.length - 1);
};
this._setFocusedComment(event.equals(KeyCode.UpArrow) ? moveFocusWithinBounds(-1) : moveFocusWithinBounds(1));
}
}));

Up- / down-arrow navigation between comments in a thread also happens when the focused comment has been toggled into edit mode. This means a keyboard-only user can only navigate to the next line of a multi-line comment by using the right-arrow key repeatedly.

Also, I didn't find a keyboard-only way to set focus into a comment in a thread. So perhaps it's premature to be worrying about keyboard-based scrolling of a scrollable display-mode comment which this PR introduces. Instead I suggest opening an issue about accessibility of comments in general, and merging this PR as-is.

@alexr00 alexr00 merged commit b02700c into microsoft:main Apr 20, 2023
7 checks passed
@gjsjohnmurray gjsjohnmurray deleted the do-174629 branch April 20, 2023 08:09
@alexr00
Copy link
Member

alexr00 commented Apr 20, 2023

Also, I didn't find a keyboard-only way to set focus into a comment in a thread.

You should be able to tab and arrow through them.

@gjsjohnmurray
Copy link
Contributor Author

You should be able to tab and arrow through them.

But how do I get focus into the zonewidget in the first place, assuming I start in the editor and run Comments: Expand All Comments from Command Palette to make it appear?

@alexr00
Copy link
Member

alexr00 commented Apr 20, 2023

Command "Go to Next Comment Thread".

@gjsjohnmurray
Copy link
Contributor Author

@alexr00 many thanks for accepting this PR. Now it's landed in Insiders I've posted about it here:

https://community.intersystems.com/post/upcoming-vs-code-enhancement-improves-gj-codespex-experience

@kazemicode
Copy link

kazemicode commented May 9, 2023

@alexr00 and @gjsjohnmurray I think this PR actually went against my team's use case, where we PREFER the longer comment height to show animated GIFs when we use the CodeTour extension to walk our learners through hands on labs. The max height now means that our learners cannot see the full image on their screen, which detracts from our learner experience. Is there a way for the end user to specify a max height instead of imposing a default max height?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants