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

Fix scroll to row #803

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions addon/components/lt-body.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
{{if this.canSelect "can-select"}}
{{if this.multiSelect "multi-select"}}
{{if this.canExpand "can-expand"}}"
{{did-insert this.onRowsChange this.rows}}
{{did-update this.onRowsChange this.rows}}
{{did-insert this.scheduleScrolledToBottom this.rows this.isInViewport}}
{{did-update this.scheduleScrolledToBottom this.rows this.isInViewport}}
{{did-insert this.onRowsChange this.rows}}
{{did-update this.onRowsChange this.rows}}
{{did-insert this.scheduleScrolledToBottom this.rows this.isInViewport}}
{{did-update this.scheduleScrolledToBottom this.rows this.isInViewport}}
{{did-insert this.setupScrollOffset this.scrollTo this.scrollToRow}}
{{did-update this.setupScrollOffset this.scrollTo this.scrollToRow}}
>
{{#let
(hash
Expand Down Expand Up @@ -56,9 +58,16 @@
{{/vertical-collection}}
{{yield
(hash
loader=(component (ensure-safe-component lt.spanned-row) classes="lt-is-loading")
no-data=(component (ensure-safe-component lt.spanned-row) classes="lt-no-data")
expanded-row=(component (ensure-safe-component lt.spanned-row) visible=false)
loader=(component
(ensure-safe-component lt.spanned-row)
classes="lt-is-loading"
)
no-data=(component
(ensure-safe-component lt.spanned-row) classes="lt-no-data"
)
expanded-row=(component
(ensure-safe-component lt.spanned-row) visible=false
)
)
this.rows
}}
Expand Down Expand Up @@ -133,8 +142,12 @@
yield=row
visible=row.expanded
)
loader=(component (ensure-safe-component lt.spanned-row) visible=false)
no-data=(component (ensure-safe-component lt.spanned-row) visible=false)
loader=(component
(ensure-safe-component lt.spanned-row) visible=false
)
no-data=(component
(ensure-safe-component lt.spanned-row) visible=false
)
)
this.rows
}}
Expand All @@ -143,12 +156,18 @@
{{yield
(hash
loader=(component
(ensure-safe-component lt.spanned-row) classes="lt-is-loading" colspan=this.colspan
(ensure-safe-component lt.spanned-row)
classes="lt-is-loading"
colspan=this.colspan
)
no-data=(component
(ensure-safe-component lt.spanned-row) classes="lt-no-data" colspan=this.colspan
(ensure-safe-component lt.spanned-row)
classes="lt-no-data"
colspan=this.colspan
)
expanded-row=(component
(ensure-safe-component lt.spanned-row) visible=false
)
expanded-row=(component (ensure-safe-component lt.spanned-row) visible=false)
)
this.rows
}}
Expand Down
11 changes: 3 additions & 8 deletions addon/components/lt-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,6 @@ export default Component.extend({
once(this, this._setupVirtualScrollbar);
},

didReceiveAttrs() {
this._super(...arguments);
this.setupScrollOffset();
},

destroy() {
this._super(...arguments);
this._cancelTimers();
Expand All @@ -371,7 +366,7 @@ export default Component.extend({
);
}),

setupScrollOffset() {
setupScrollOffset: action(function (element) {
let { scrollTo, _scrollTo, scrollToRow, _scrollToRow } = this;
let targetScrollOffset = null;

Expand All @@ -390,7 +385,7 @@ export default Component.extend({
});
} else if (scrollToRow !== _scrollToRow) {
if (scrollToRow instanceof Row) {
let rowElement = this.element.querySelector(
let rowElement = element.querySelector(
`[data-row-id=${scrollToRow.get('rowId')}]`
);

Expand All @@ -404,7 +399,7 @@ export default Component.extend({
hasReachedTargetScrollOffset: true,
});
}
},
}),

checkTargetScrollOffset() {
if (!this.hasReachedTargetScrollOffset) {
Expand Down