Skip to content

Feat #6850: add updateDetailView and updateDetailViewByUniqueId methods - #8583

Merged
wenzhixin merged 3 commits into
developfrom
feature/6850
Nov 14, 2026
Merged

wenzhixin merged 3 commits into
developfrom
feature/6850

Conversation

@wenzhixin

@wenzhixin wenzhixin commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

🤔Type of Request

  • Bug fix
  • New feature
  • Improvement
  • Documentation
  • Other

🔗Resolves an issue?
Fix #6850
Refs #6243

📝Changelog

  • Core
  • Extensions

Previously, the detail view content was a snapshot rendered when the row was expanded: updateCell/updateCellByUniqueId did not touch it, and initBody preserved the old detail DOM as-is. The new methods re-run detailFormatter on the expanded row (silently ignored if the row is not expanded) and trigger an update-detail-view event (index, row, $element), consistent with the existing expand-row/collapse-row event-only style.

Unit tests added in tests/modules/detail.test.js (expanded/not-expanded/unknown-id cases); all 557 tests pass.

💡Example(s)?

  • Before: https://live.bootstrap-table.com/code/wenzhixin/20004 — rebuilt on develop because the original issue example was lost. Expand "Item 3", click updateCellByUniqueId: the row updates but the expanded detail view keeps the old value, and updateDetailViewByUniqueId is not available yet.
  • After: https://live.bootstrap-table.com/code/wenzhixin/20005 — commit 661d0102 on feature/6850. Repeat the steps, then click updateDetailViewByUniqueId: the detail view re-renders to the new value and the update-detail-view event fires.

☑️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

@wenzhixin wenzhixin left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Pull request overview

Adds updateDetailView(index) and updateDetailViewByUniqueId(uniqueId) methods to re-render the detail view of an already-expanded row after the underlying data changes (fixes #6850, refs #6243). Both methods no-op silently when the row is not expanded and mirror the existing expandRow/collapseRow DOM handling.

Changes:

  • src/modules/detail.js: two new methods
  • src/constants/index.js: register both names in METHODS
  • site/src/pages/docs/api/methods.mdx (en + zh-cn): document both methods
  • tests/modules/detail.test.js: 5 unit tests

Reviewed changes

Reviewed 5 out of 5 changed files and generated 1 comment.

File Description
src/modules/detail.js New methods + event trigger
src/constants/index.js METHOD registration
site/src/pages/docs/api/methods.mdx en docs
site/src/pages/zh-cn/docs/api/methods.mdx zh-cn docs
tests/modules/detail.test.js Unit tests

Verification

  • npx vitest run tests/modules/detail.test.js → 5/5 pass.
  • Confirmed Constants.EVENTS has no update-detail-view.bs.table entry and DEFAULTS has no onUpdateDetailView, so trigger('update-detail-view', ...) resolves this.options[undefined] and throws (see inline comment).
  • CI Test/test is failing at docs:check:api (see finding 3 below).
  • Static review only; no full CI run locally.

Findings

  1. Blocking — updateDetailView throws a TypeError on every call (inline comment on src/modules/detail.js:96). The new update-detail-view event is not registered in Constants.EVENTS, and there is no onUpdateDetailView default, but trigger() (bootstrap-table.js:46-54) unconditionally calls this.options[BootstrapTable.EVENTS[name]](...). The unit test does not catch this because it stubs trigger. Fix: add 'update-detail-view.bs.table': 'onUpdateDetailView' to EVENTS plus an onUpdateDetailView: () => false default (and document it in events.mdx), matching the expand-row/collapse-row pattern.

  2. Suggestion — updateDetailView always uses this.options.detailFormatter, whereas expandRow prefers the per-column detailFormatter (_columnDetailFormatter, populated from column.detailFormatter via header.detailFormatters). If a table uses only a column-level detailFormatter and no table-level one, calling updateDetailView re-renders with undefined → the detail content is emptied. Consider accepting an optional formatter argument (like expandRow) or documenting the limitation.

  3. Note (cross-repo ordering) — CI Test/test fails at docs:check:api because site/.../methods.mdx links to update-detail-view.html / update-detail-view-by-unique-id.html, which only exist in the not-yet-merged examples PR wenzhixin/bootstrap-table-examples#592. Merge #592 first, then re-run CI on this PR.

Recommendation: needs changes — fix the unregistered update-detail-view event before merging.

Comment thread src/modules/detail.js Resolved

@wenzhixin wenzhixin left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Pull request overview

Follow-up review after the update to 661d0102. This PR adds updateDetailView / updateDetailViewByUniqueId methods that re-render an expanded detail view (fixes #6850).

This second pass covers the incremental changes since the previously reviewed head 066d6ef1.

Changes since 066d6ef1:

  • Blocking finding resolved: update-detail-view.bs.table is now registered in Constants.EVENTS (src/constants/index.js:519) with an onUpdateDetailView: (index, row, $element) => false default (:341), matching the expand-row/collapse-row pattern. The signature matches the runtime call this.trigger('update-detail-view', index, row, $element) (src/modules/detail.js:96). Documented in events.mdx (en + zh-cn), which also unblocks docs:check:api (examples #592 is merged).
  • Test hardening: the trigger mock in tests/modules/detail.test.js now resolves the handler through Constants.EVENTS, so an unregistered event would fail the test instead of being hidden by a no-op stub — exactly the regression coverage gap pointed out last round.

However, the fix introduced a new blocking issue:

  • The new onUpdateDetailView default was not propagated to the generated type artifacts. CI fails at types:check because regenerating produces drift (index.d.ts missing 'update-detail-view.bs.table': string in BootstrapTableEvents and onUpdateDetailView?: Function in BootstrapTableOptions; tests/types/generated-options.test.ts missing the onUpdateDetailView self-assignment). I reproduced this locally by running node tools/create-d-ts.js — it adds exactly those 3 lines. Please run yarn types:build and commit the updated index.d.ts + tests/types/generated-options.test.ts.

Reviewed changes

Reviewed 4 out of 4 incrementally changed files (the full PR spans 10 files) and generated 1 comment.

File Description
src/constants/index.js Register update-detail-view.bs.table event + onUpdateDetailView default
site/src/pages/docs/api/events.mdx Document onUpdateDetailView (en)
site/src/pages/zh-cn/docs/api/events.mdx Document onUpdateDetailView (zh-cn)
tests/modules/detail.test.js Rework trigger mock to resolve handlers via Constants.EVENTS

Verification

  • Ran npx vitest run tests/modules/detail.test.js locally: 5/5 pass, including the reworked trigger mock path.
  • Ran node tools/create-d-ts.js locally: reproduces the CI drift (3 missing generated lines), confirming the CI failure cause.
  • Static check: EVENTS mapping ↔ DEFAULTS callback ↔ runtime trigger args ↔ events.mdx parameter list are consistent (index, row, $element).
  • CI Test/test currently red at types:check; Test/changes green.

Remaining notes (non-blocking)

  • Column-level detailFormatter (via header.detailFormatters) is still ignored by updateDetailView — it always uses the global this.options.detailFormatter. Unchanged from last round; fine as a follow-up.
  • Static review only for the rest; no other CI run locally.

Recommendation: Needs one more change — run yarn types:build and commit the regenerated artifacts to clear types:check, then this is good to merge.

Comment thread src/constants/index.js Resolved

@wenzhixin wenzhixin left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Pull request overview

Follow-up review after the update to e67715fb. This PR adds updateDetailView(index) and updateDetailViewByUniqueId(uniqueId) methods that re-render the detail view of an already-expanded row (fixes #6850).

This third pass covers only the incremental changes from the previously reviewed head 661d0102. The single blocker from round 2 — stale generated type artifacts after adding the onUpdateDetailView default — is resolved.

Changes since 661d0102:

  • Ran yarn types:build and committed the regenerated artifacts: index.d.ts now includes 'update-detail-view.bs.table': string (BootstrapTableEvents) and onUpdateDetailView?: Function (BootstrapTableOptions), and tests/types/generated-options.test.ts includes the onUpdateDetailView self-assignment — exactly the three lines flagged in round 2.

Reviewed changes

Reviewed 2 out of 2 incrementally changed files (the full PR spans 12 files) and generated no new comments.

File Description
index.d.ts Regenerated: adds the update-detail-view.bs.table event key and the onUpdateDetailView option
tests/types/generated-options.test.ts Regenerated: adds the onUpdateDetailView self-assignment

Verification

  • Re-ran node tools/create-d-ts.js on this head: zero drift against the committed artifacts (281 options / 32 events).
  • Frozen-contract check against origin/develop: no key removed from any of the 5 interfaces, interface name set and declare global block unchanged.
  • npx vitest run tests/modules/detail.test.js: 5/5 passing.
  • Confirmed the en/zh events.mdx documentation declares onUpdateDetailView with parameters index, row, $element, matching the runtime trigger call.
  • CI: Test/changes and Test/test both green on e67715fb (the types:check drift gate is included in the test job). Static review plus the module test suite; no other CI run locally.

Remaining notes (non-blocking)

  • onUpdateDetailView is typed as bare Function (same style as onVirtualScroll and other handlers without a type-overrides.js entry), so TS users don't get parameter checking for (index, row, $element). Adding a precise override in tools/type-overrides.js — like onExpandRow already has — would be a nice follow-up.
  • The round-1 suggestion about updateDetailView only using the global options.detailFormatter (ignoring column-level column.detailFormatter via _columnDetailFormatter) remains unaddressed; acceptable as a documented limitation or follow-up.

Recommendation: good to merge.

@wenzhixin

Copy link
Copy Markdown
Owner Author

两条 non-blocking notes 已在 57f8fdf 中处理:

  • onUpdateDetailView 精确签名:在 tools/type-overrides.js 中仿 onExpandRow 添加了 (index: number, row: any, $element: JQuery<HTMLElement>) => boolean | void 覆盖,并重新生成了 index.d.ts(裸 Function → 精确签名)。
  • 列级 detailFormatter:updateDetailView 现在接受可选的第二个参数 _columnDetailFormatter(与 expandRow 对称),传入时优先于表级 options.detailFormatter;补了对应单测。

验证:yarn types:check(零 drift + tsc)、yarn lint:js、yarn docs:check:api、vitest tests/modules/detail.test.js(6/6)全部通过。

@wenzhixin wenzhixin left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Pull request overview

Follow-up review after the force-push to 57f8fdf2. This PR adds updateDetailView(index) / updateDetailViewByUniqueId(uniqueId) methods that re-render the detail view of an expanded row (#6850).

This pass covers only the incremental changes since the previously reviewed head e67715fb (one commit, 4 files). It resolves the two non-blocking items left from earlier rounds: onUpdateDetailView now has a precise signature instead of a bare Function, and updateDetailView now honors the column-level detail formatter.

Changes since e67715fb:

  • Precise event signature: tools/type-overrides.js now types onUpdateDetailView as (index: number, row: any, $element: JQuery<HTMLElement>) => boolean | void, and the regenerated index.d.ts carries the same signature, matching the runtime trigger('update-detail-view', index, row, $element) call (src/modules/detail.js:97).
  • Column-level detail formatter: updateDetailView accepts an optional _columnDetailFormatter second parameter and falls back to this.options.detailFormatter — mirroring expandRow (src/modules/detail.js:32 vs :90). Previously, re-rendering a row expanded via a column-level formatter would have produced empty content.
  • New test: "prefers the column detail formatter over the table-level one" asserts the formatter receives (index, row, $element) and the table-level formatter is not called.

Reviewed changes

Reviewed 4 out of 4 incrementally changed files (the full PR spans 12 files) and generated no new comments.

File Description
src/modules/detail.js Add optional _columnDetailFormatter param with the same fallback as expandRow
tools/type-overrides.js Precise onUpdateDetailView signature
index.d.ts Regenerated; onUpdateDetailView signature updated
tests/modules/detail.test.js New test for column-level formatter precedence

Verification

  • Regenerated types via node tools/create-d-ts.js: zero drift against the committed artifacts.
  • Frozen contract check vs develop: no keys removed from any interface, interface set and declare global block unchanged.
  • npx vitest run tests/modules/detail.test.js: 6/6 pass (including the new column-formatter test).
  • Signature consistency confirmed across all four places: tools/type-overrides.js:120, index.d.ts:328, tests/types/generated-options.test.ts:179, and the runtime trigger site src/modules/detail.js:97.
  • Cross-checked the formatter plumbing: the only producer of column-level formatters is body.js:46 (this.header.detailFormatters[...] on the icon-click path), and updateDetailViewByUniqueId not forwarding a formatter matches the expandRowByUniqueId convention. The _columnDetailFormatter param is intentionally undocumented, consistent with how toggleDetailView documents only index.
  • CI Test/changes + Test/test green (static review only beyond the checks listed here).

Remaining notes (non-blocking)

  • none — all prior findings (including the two informational/suggestion-level items from rounds 2–3) are now addressed.

Recommendation: good to merge.

@wenzhixin
wenzhixin merged commit b2906ff into develop Nov 14, 2026
2 checks passed
@wenzhixin
wenzhixin deleted the feature/6850 branch November 14, 2026 09:44
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.

Detail view formatter not called when table data is updated

1 participant