Skip to content

Adjust scroll behavior when elements resize - #193530

Closed
Aaron Munger (amunger) wants to merge 12 commits into
mainfrom
aamunger/scrollOnResize
Closed

Aaron Munger (amunger) wants to merge 12 commits into
mainfrom
aamunger/scrollOnResize

Conversation

@amunger

@amunger Aaron Munger (amunger) commented Sep 19, 2023 •

Copy link
Copy Markdown
Collaborator

fix #193231
fix #193835

The previous behavior changed depending on whether the resizing element was only partially visible.
This will drop that variability and instead, just prevent the resizing element from leaving the view entirely.

@amunger

Copy link
Copy Markdown
Collaborator Author

João Moreno (@joaomoreno) - could you take a look at the change to listview.updateElementHeight here? I don't think there's a better way to manually adjust the scroll top at the same time that an element is resized, but I'm open to suggestions.

Comment thread src/vs/base/browser/ui/list/listView.ts Outdated
}

updateElementHeight(index: number, size: number | undefined, anchorIndex: number | null): void {
updateElementHeight(index: number, size: number | undefined, anchorIndex: number | null, renderTopOverride?: number | undefined): void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a huge fan of conflating view model operations (updateElementHeight) with view properties (renderTopOverride). Did you find any other way to solve this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In other words, would there be a better default other than Math.max(0, this.lastRenderTop + heightDiff) that would fix this issue and play nicely with all other lists?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This new behavior will keep the last line in view, and knowing the amount of padding to be able to do that is pretty specific to the type of items in the list, so it would not be straight forward for the listview to take care of this.

Updating element height seems pretty tightly coupled with rendering at a specific render top in the current implementation, but I could look at other options for adjusting those two pieces separately, (like adding the renderTopOverride to rerender?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I pushed a commit with an alternative, keeping the scrolltop calculations within the updateElementHeight method. I can clean up the parameters a bit more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Peng Lyu (@rebornix) suggested that we go the other way, and make users of updateElementHeight calculate and pass in a render top override if needed. That will simplify listView's updateElementHeight implementation and should allow more explicit control to the users of that function, so I like that idea

@joaomoreno João Moreno (joaomoreno) added the under-discussion Issue is under discussion for relevance, priority, approach label Sep 22, 2023
@joaomoreno João Moreno (joaomoreno) removed this from the September 2023 milestone Sep 22, 2023
@amunger

Copy link
Copy Markdown
Collaborator Author

with #193833 to take care of the inconsistent anchor behavior, this will take care of #193835 instead, which is not as impactful

@joaomoreno

Copy link
Copy Markdown
Contributor

Holding off review until #193231 is stabilized.

@amunger

Copy link
Copy Markdown
Collaborator Author

closing this for now after the improvements from #194516.
We'll see if we get any feedback that makes us revisit.

@github-actions github-actions Bot locked and limited conversation to collaborators Dec 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

under-discussion Issue is under discussion for relevance, priority, approach

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Executing cell can resize itself out of view notebook scrolls up incorrectly when adjusting output heights

3 participants