bootstrap-table
bootstrap-table copied to clipboard
Sticky header attempts to render, while not initialized
Bootstraptable version(s) affected
1.22.2
Description
When combining the filter-control and sticky-header, we get an error in console. See https://live.bootstrap-table.com/code/vever001/17062
Uncaught TypeError: Cannot read properties of undefined (reading 'offset')
at p.value (bootstrap-table-sticky-header.min.js:10:20501)
at p.value (bootstrap-table-sticky-header.min.js:10:19051)
at bootstrap-table-filter-control.min.js:10:49522
It seems the onColumnSearch
gets called from here, and calls this.renderStickyHeader()
without checking if sticky headers is enabled on the table or not (while the sticky header may not have been initialized).
Example(s)
https://live.bootstrap-table.com/code/vever001/17062
Possible Solutions
Add a check for this.options.stickyHeader
?
Additional Context
FWIW we made a temp workaround as follows for now:
$.BootstrapTable = class extends $.BootstrapTable {
renderStickyHeader () {
if (this.options.stickyHeader) {
super.renderStickyHeader();
}
}
}
A PR is welcome.
Just created the PR which fixes the issue for me at least.