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

Making the sticky scroll keep focus when the sticky lines disappear on scrolling #177813

Merged
merged 1 commit into from Mar 21, 2023

Conversation

aiday-mar
Copy link
Contributor

Fixes #177770

@aiday-mar aiday-mar added feature-request Request for new features or functionality bug Issue identified by VS Code Team member as probable bug editor-sticky-scroll verification-needed Verification of issue is requested and removed feature-request Request for new features or functionality labels Mar 21, 2023
@aiday-mar aiday-mar added this to the March 2023 milestone Mar 21, 2023
@aiday-mar aiday-mar marked this pull request as ready for review March 21, 2023 13:51
this._stickyScrollWidget.setState(this._widgetState);
this._focusedStickyElementIndex = this._stickyElements.length - 1;
if (this._focusedStickyElementIndex !== -1) {
(this._stickyElements.item(this._focusedStickyElementIndex) as HTMLDivElement).focus();
Copy link
Member

Choose a reason for hiding this comment

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

You could store _stickyElements as a HTMLElement[] to avoid these casts spread throughout the file:

this._stickyElements = Array.from(this._stickyScrollWidget.getDomNode().childNodes) as HTMLElement[]

You should also be able to use HTMLElement here instead of the more specific HTMLDivElement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip! The issue is that I need to access the original children HTML elements. The above code creates a copy.

@aiday-mar aiday-mar merged commit 7a5c032 into main Mar 21, 2023
6 checks passed
@aiday-mar aiday-mar deleted the aiday/issue177770 branch March 21, 2023 15:04
@aiday-mar aiday-mar removed the verification-needed Verification of issue is requested label Mar 21, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-sticky-scroll
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Focus sticky scroll is not preserved when sticky lines disappear and reapper
2 participants