-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(cdk/scrolling): fix scrolling in appendOnly mode #24153
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
Conversation
@@ -174,7 +174,8 @@ export class FixedSizeVirtualScrollStrategy implements VirtualScrollStrategy { | |||
} | |||
|
|||
this._viewport.setRenderedRange(newRange); | |||
this._viewport.setRenderedContentOffset(this._itemSize * newRange.start); | |||
const newRangeStart = this._viewport.getRenderedRange().start * this._itemSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change doesn't seem quite right to me. I notice that setRenderedRange
is special-cased for append only mode, I think setRenderedContentOffset
may need something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the point, it's the responsability of the viewport to do this logic, otherwise it would be in all classes implementing VirtualScrollStrategy
8c95608
to
25d455d
Compare
@@ -321,6 +321,8 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O | |||
const axis = isHorizontal ? 'X' : 'Y'; | |||
const axisDirection = isHorizontal && isRtl ? -1 : 1; | |||
let transform = `translate${axis}(${Number(axisDirection * offset)}px)`; | |||
// in appendOnly, we always start from the top |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmalerba I've moved the logic to the virtual-scroll-viewport
and added two tests.
I'm wondering if we need to update the offset when to
is set to to-end
. I've added a unit test for this case and the offset is correctly set. I think it's because we are recalculating the values with 'to-start' afterward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thanks!
The rendered content offset is incorrectly set in appendOnly. It should be set to 0.
25d455d
to
7d90d41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The rendered content offset is incorrectly set in appendOnly. It should be set to 0. (cherry picked from commit 5221b79)
Thanks for taking care and fixing my raised issue! |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/cdk](https://github.com/angular/components) | dependencies | patch | [`13.2.1` -> `13.2.2`](https://renovatebot.com/diffs/npm/@angular%2fcdk/13.2.1/13.2.2) | | [@angular/material](https://github.com/angular/components) | dependencies | patch | [`13.2.1` -> `13.2.2`](https://renovatebot.com/diffs/npm/@angular%2fmaterial/13.2.1/13.2.2) | --- ### Release Notes <details> <summary>angular/components</summary> ### [`v13.2.2`](https://github.com/angular/components/blob/HEAD/CHANGELOG.md#​1322-enamel-eagle-2022-02-09) [Compare Source](angular/components@13.2.1...13.2.2) ##### cdk | Commit | Type | Description | | -- | -- | -- | | [4b6e83274](angular/components@4b6e832) | fix | **scrolling:** fix scrolling in appendOnly mode ([#​24153](angular/components#24153)) | ##### material | Commit | Type | Description | | -- | -- | -- | | [f5199eeeb](angular/components@f5199ee) | fix | **datepicker:** fix improper focus trapping with VoiceOver and ChromeVox ([#​24300](angular/components#24300)) | | [a72bcbe50](angular/components@a72bcbe) | fix | **datepicker:** remove abbr from day of week header ([#​24106](angular/components#24106)) | ##### material-experimental | Commit | Type | Description | | -- | -- | -- | | [3bbcb444f](angular/components@3bbcb44) | fix | **mdc-checkbox:** add missing classes for checked ([#​24350](angular/components#24350)) | ##### material-experiental | Commit | Type | Description | | -- | -- | -- | | [70bec6054](angular/components@70bec60) | fix | **mdc-list:** update material-components-web to pick up multi-select list keyboard support ([#​24354](angular/components#24354)) | #### Special Thanks Alan Agius, Artur Androsovych, Chabbey François, Joey Perrott, Kristiyan Kostadinov, Miles Malerba, Paul Gschwendtner, Zach Arend and renovate\[bot] <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1161 Reviewed-by: Epsilon_02 <[email protected]> Co-authored-by: Calciumdibromid Bot <[email protected]> Co-committed-by: Calciumdibromid Bot <[email protected]>
The rendered content offset is incorrectly set in appendOnly. It should be set to 0.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hi,
This fixes #23577
The rendered content offset is incorrectly set in appendOnly; it should not change. This causes a weird behavior where the list jumps to the top
CC: @MichaelJamesParsons as you added the appendOnly flag in 8f052cc,, and @mmalerba as ( I think ) your are the main author for the virtual-scrolling