Skip to content
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

Fixed insertRow bug after on last row of table #7647

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,11 @@ class BootstrapTable {
const row = this.data[params.index]
const originalIndex = this.options.data.indexOf(row)

if (originalIndex === -1) {
this.append([params.row])
return
}

this.data.splice(params.index, 0, params.row)
this.options.data.splice(originalIndex, 0, params.row)
this.initSearch()
Expand Down
19 changes: 6 additions & 13 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,20 @@ export default {
getBootstrapVersion () {
let bootstrapVersion = 5

try {
const rawVersion = $.fn.dropdown.Constructor.VERSION
if (typeof window !== 'undefined' && window.bootstrap?.Tooltip?.VERSION) {
const rawVersion = window.bootstrap.Tooltip.VERSION

// Only try to parse VERSION if it is defined.
// It is undefined in older versions of Bootstrap (tested with 3.1.1).
if (rawVersion !== undefined) {
bootstrapVersion = parseInt(rawVersion, 10)
}
} catch (e) {
console.error(e)
}

try {
// eslint-disable-next-line no-undef
const rawVersion = bootstrap.Tooltip.VERSION
} else if (typeof $ !== 'undefined' && $.fn?.dropdown?.Constructor?.VERSION) {
const rawVersion = $.fn.dropdown.Constructor.VERSION

// Only try to parse VERSION if it is defined.
// It is undefined in older versions of Bootstrap (tested with 3.1.1).
if (rawVersion !== undefined) {
bootstrapVersion = parseInt(rawVersion, 10)
}
} catch (e) {
console.error(e)
}

return bootstrapVersion
Expand Down
Loading