Fix filter-control select option loss and sticky-header undefined crash#8292
Conversation
There was a problem hiding this comment.
Pull request overview
Bug fix PR addressing two regressions in extensions: filter-control select state handling and sticky-header crashes when anchor/container elements are missing.
Changes:
- Update filter-control select handling to use
prop('selected', ...)and:selectedinstead ofattr()/[selected]. - Add guards in sticky-header to avoid
offset()crashes when sticky anchor elements are missing/undefined.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/extensions/sticky-header/bootstrap-table-sticky-header.js |
Adds conditional guards around sticky anchor/container usage to prevent offset() access on missing elements. |
src/extensions/filter-control/utils.js |
Adjusts select-option selection logic to use property-based selection APIs to prevent lost selections / repeated change behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
90dfe32 to
1bc64a2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1bc64a2 to
0d754d4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/extensions/sticky-header/bootstrap-table-sticky-header.js:104
- The delegated events are bound with
on('keyup change mouse', ...)butmouseis not a valid DOM/jQuery event type (and it also doesn’t match theoff('... mouseup')call). This means the intendedmouseuphandling won’t run for sticky header filter controls. Update the event list to usemouseup(or remove it entirely if not needed).
if (this.options.filterControl) {
$(this.$stickyHeader).off('keyup change mouseup').on('keyup change mouse', function (e) {
const $target = $(e.target)
src/extensions/filter-control/utils.js:481
- Setting the select value to
[]whenvalue === nullcan introduce array values for<select multiple>.onColumnSearchinsrc/extensions/filter-control/bootstrap-table-filter-control.jscurrently treats$element.val()as a string and calls.trim(), which will throw for arrays—particularly when clearing a multi-select (null -> []). Prefer leaving the value asnullwhen nothing is selected, or adjustonColumnSearchto handle array values (e.g., join with a delimiter) before trimming.
const $selectControl = $(currentTarget)
const value = $selectControl.val()
$selectControl.val(value === null ? $selectControl.prop('multiple') ? [] : null : value)
clearTimeout(currentTarget.timeoutId || 0)
currentTarget.timeoutId = setTimeout(() => {
that.onColumnSearch({ currentTarget, keyCode })
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Good suggestion. We plan to add Cypress tests for select filter controls (single-select, multi-select, and clearing scenarios) in a separate PR to keep this bug fix focused. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/extensions/sticky-header/bootstrap-table-sticky-header.js:104
- The event names passed to
off(...)andon(...)don’t match (mouseupvsmouse). This means handlers attached for themouseevent will never be removed on subsequentrenderStickyHeader()calls, andmouseis not a standard DOM/jQuery event name. Align the event list sooffremoves exactly whatonregisters (likelymouseup), to avoid handler accumulation and unexpected behavior.
if (this.options.filterControl) {
$(this.$stickyHeader).off('keyup change mouseup').on('keyup change mouse', function (e) {
const $target = $(e.target)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0d754d4 to
3ba8a80
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🤔Type of Request
🔗Resolves an issue?
Fix #6950
📝Changelog
on changeevent firing multiple times and selected option being lost, by replacing manual option toggle with.val()for reliable value syncingCannot read properties of undefined (reading 'offset')error when$stickyBegin/$stickyEnd/$stickyContainerare undefined💡Example(s)?
☑️Self Check before Merge