Skip to content

Fix filter-control select option loss and sticky-header undefined crash#8292

Merged
wenzhixin merged 1 commit into
developfrom
feature/fix-filter-control-select-and-sticky-header-crash
Apr 15, 2026
Merged

Fix filter-control select option loss and sticky-header undefined crash#8292
wenzhixin merged 1 commit into
developfrom
feature/fix-filter-control-select-and-sticky-header-crash

Conversation

@wenzhixin

@wenzhixin wenzhixin commented Apr 15, 2026

Copy link
Copy Markdown
Owner

🤔Type of Request

  • Bug fix

🔗Resolves an issue?
Fix #6950

📝Changelog

  • Core
  • Extensions
  • Fixed filter-control select on change event firing multiple times and selected option being lost, by replacing manual option toggle with .val() for reliable value syncing
  • Fixed sticky-header Cannot read properties of undefined (reading 'offset') error when $stickyBegin / $stickyEnd / $stickyContainer are undefined

💡Example(s)?

☑️Self Check before Merge

⚠️ Please check all items below before reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :selected instead of attr() / [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.

Comment thread src/extensions/sticky-header/bootstrap-table-sticky-header.js Outdated
Comment thread src/extensions/filter-control/utils.js Outdated
Comment thread src/extensions/sticky-header/bootstrap-table-sticky-header.js Outdated
@wenzhixin wenzhixin force-pushed the feature/fix-filter-control-select-and-sticky-header-crash branch from 90dfe32 to 1bc64a2 Compare April 15, 2026 01:08
@wenzhixin wenzhixin requested a review from Copilot April 15, 2026 01:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/extensions/sticky-header/bootstrap-table-sticky-header.js Outdated
Comment thread src/extensions/filter-control/utils.js Outdated
@wenzhixin wenzhixin force-pushed the feature/fix-filter-control-select-and-sticky-header-crash branch from 1bc64a2 to 0d754d4 Compare April 15, 2026 01:15
@wenzhixin wenzhixin requested a review from Copilot April 15, 2026 01:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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', ...) but mouse is not a valid DOM/jQuery event type (and it also doesn’t match the off('... mouseup') call). This means the intended mouseup handling won’t run for sticky header filter controls. Update the event list to use mouseup (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 [] when value === null can introduce array values for <select multiple>. onColumnSearch in src/extensions/filter-control/bootstrap-table-filter-control.js currently 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 as null when nothing is selected, or adjust onColumnSearch to 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.

Comment thread src/extensions/filter-control/utils.js
Comment thread src/extensions/filter-control/utils.js
@wenzhixin

Copy link
Copy Markdown
Owner Author

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...) and on(...) don’t match (mouseup vs mouse). This means handlers attached for the mouse event will never be removed on subsequent renderStickyHeader() calls, and mouse is not a standard DOM/jQuery event name. Align the event list so off removes exactly what on registers (likely mouseup), 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.

Comment thread src/extensions/sticky-header/bootstrap-table-sticky-header.js Outdated
@wenzhixin wenzhixin force-pushed the feature/fix-filter-control-select-and-sticky-header-crash branch from 0d754d4 to 3ba8a80 Compare April 15, 2026 01:35
@wenzhixin wenzhixin requested a review from Copilot April 15, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@wenzhixin wenzhixin merged commit be14412 into develop Apr 15, 2026
5 checks passed
@wenzhixin wenzhixin deleted the feature/fix-filter-control-select-and-sticky-header-crash branch April 15, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants