-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Fix #8123 #8128
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
base: develop
Are you sure you want to change the base?
Fix #8123 #8128
Changes from all commits
4026556
7956404
40829bb
eeebcd4
3f0f7d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| describe('Auto Refresh', () => { | ||
| it('should toggle active state', () => { | ||
| cy.visit('cypress/e2e/extensions/auto-refresh/test.html') | ||
| cy.get('[name="autoRefresh"]').click() | ||
| cy.get('[name="autoRefresh"]').should('have.class', 'active') | ||
| cy.get('[name="autoRefresh"]').click() | ||
| cy.get('[name="autoRefresh"]').should('not.have.class', 'active') | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Auto Refresh Test</title> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
| <link rel="stylesheet" href="../../../../dist/bootstrap-table.min.css"> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
| <table id="table" data-toggle="table" data-pagination="true" data-search="true" data-auto-refresh="true"> | ||
| <thead> | ||
| <tr> | ||
| <th data-field="id">ID</th> | ||
| <th data-field="name">Name</th> | ||
| <th data-field="price">Price</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr> | ||
| <td>1</td> | ||
| <td>Item 1</td> | ||
| <td>$1</td> | ||
| </tr> | ||
| <tr> | ||
| <td>2</td> | ||
| <td>Item 2</td> | ||
| <td>$2</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
|
|
||
| <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
| <script src="../../../../dist/bootstrap-table.min.js"></script> | ||
| <script src="../../../../src/extensions/auto-refresh/bootstrap-table-auto-refresh.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,7 +11,7 @@ Object.assign($.fn.bootstrapTable.defaults, { | |||||
| showAutoRefresh: true, | ||||||
| autoRefreshInterval: 60, | ||||||
| autoRefreshSilent: true, | ||||||
| autoRefreshStatus: true, | ||||||
| autoRefreshStatus: false, | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the default value here be modified? |
||||||
| autoRefreshFunction: null | ||||||
| }) | ||||||
|
|
||||||
|
|
@@ -42,16 +42,22 @@ $.BootstrapTable = class extends $.BootstrapTable { | |||||
|
|
||||||
| initToolbar (...args) { | ||||||
| if (this.options.autoRefresh) { | ||||||
| this.buttons = Object.assign(this.buttons, { | ||||||
| const attributes = { | ||||||
| 'aria-label': this.options.formatAutoRefresh(), | ||||||
| title: this.options.formatAutoRefresh() | ||||||
| } | ||||||
|
|
||||||
| if (this.options.autoRefreshStatus) { | ||||||
| attributes.class = this.constants.classes.buttonActive || 'active' | ||||||
| } | ||||||
|
|
||||||
| this.buttons = Object.assign(this.buttons || {}, { | ||||||
|
||||||
| this.buttons = Object.assign(this.buttons || {}, { | |
| Object.assign(this.buttons, { |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .bind(this) call is redundant here. The toolbar module already calls event handlers with the correct context using .call(this) (see src/modules/toolbar.js line 230). While this doesn't cause any issues, it's unnecessary and inconsistent with other extensions like copy-rows, custom-view, and filter-control which don't use .bind().
| event: this.toggleAutoRefresh.bind(this), | |
| event: this.toggleAutoRefresh, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test should verify the initial state of the auto-refresh button. Since the default value of
autoRefreshStatuswas changed tofalse, the button should not have the 'active' class when the page first loads. Consider adding an assertion before the first click to verify this initial state.