fix: account for div container during infinite scroll
why: * the top_navigation_placement feature flag introduces a wrapper div around all of Canvas, to make the Drawer implementation work * InfiniteScroll looks at the document for scroll events, but with the wrapper div there aren't any * use the wrapper div if present but fall back to the usual document-style implementation closes INTEROP-8799 flag=none test plan * create more than 50 tools in a Course or Account * easiest way to do that is to take an existing tool and in a rails console with the tool as `t`, run this: `100.times.each { |i| t.dup.tap{ |t| t.name = "test #{i}"; t.save }` * with the top_navigation_placement flag off, scrolling down to the bottom of the list of apps should load more * with the flag enabled, scrolling down won't load any more * with this commit checked out, scrolling down should always load more tools Change-Id: Ic65166fa597c296d4c010e0a87faf2992bea2b33 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/355123 Reviewed-by: Dustin Cowles <dustin.cowles@instructure.com> Reviewed-by: Tucker Mcknight <tmcknight@instructure.com> Reviewed-by: Ryan Hawkins <ryan.hawkins@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Ryan Hawkins <ryan.hawkins@instructure.com> Product-Review: Xander Moffatt <xmoffatt@instructure.com>
This commit is contained in:
parent
716108e6a5
commit
1992fb7303
|
@ -33,6 +33,9 @@ export default class InfiniteScroll extends React.Component {
|
|||
|
||||
componentDidMount() {
|
||||
this.pageLoaded = this.props.pageStart
|
||||
if (document.getElementById('drawer-layout-content')) {
|
||||
this.scrollContainer = document.getElementById('drawer-layout-content')
|
||||
}
|
||||
if (this.props.scrollContainer) {
|
||||
this.scrollContainer = this.props.scrollContainer
|
||||
}
|
||||
|
|
|
@ -123,5 +123,15 @@ describe('InfiniteScroll', () => {
|
|||
|
||||
expect(windowSpy.mock.calls.map(c => c[0])).toContain('scroll')
|
||||
})
|
||||
|
||||
it('uses top nav drawer as container if present', () => {
|
||||
const scrollContainer = document.createElement('div')
|
||||
scrollContainer.id = 'drawer-layout-content'
|
||||
document.body.append(scrollContainer)
|
||||
|
||||
const windowSpy = jest.spyOn(window, 'addEventListener')
|
||||
render(<InfiniteScroll {...defaultProps()} />)
|
||||
expect(windowSpy.mock.calls.map(c => c[0])).not.toContain('scroll')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue