Repository navigation
Feat #6850: add updateDetailView and updateDetailViewByUniqueId methods - #8583
Conversation
cb0cc23 to
1d7281d
Compare
wenzhixin
left a comment
There was a problem hiding this comment.
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 methodssrc/constants/index.js: register both names inMETHODSsite/src/pages/docs/api/methods.mdx(en + zh-cn): document both methodstests/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.EVENTShas noupdate-detail-view.bs.tableentry andDEFAULTShas noonUpdateDetailView, sotrigger('update-detail-view', ...)resolvesthis.options[undefined]and throws (see inline comment). - CI
Test/testis failing atdocs:check:api(see finding 3 below). - Static review only; no full CI run locally.
Findings
-
Blocking —
updateDetailViewthrows aTypeErroron every call (inline comment onsrc/modules/detail.js:96). The newupdate-detail-viewevent is not registered inConstants.EVENTS, and there is noonUpdateDetailViewdefault, buttrigger()(bootstrap-table.js:46-54) unconditionally callsthis.options[BootstrapTable.EVENTS[name]](...). The unit test does not catch this because it stubstrigger. Fix: add'update-detail-view.bs.table': 'onUpdateDetailView'toEVENTSplus anonUpdateDetailView: () => falsedefault (and document it inevents.mdx), matching theexpand-row/collapse-rowpattern. -
Suggestion —
updateDetailViewalways usesthis.options.detailFormatter, whereasexpandRowprefers the per-columndetailFormatter(_columnDetailFormatter, populated fromcolumn.detailFormatterviaheader.detailFormatters). If a table uses only a column-leveldetailFormatterand no table-level one, callingupdateDetailViewre-renders withundefined→ the detail content is emptied. Consider accepting an optional formatter argument (likeexpandRow) or documenting the limitation. -
Note (cross-repo ordering) — CI
Test/testfails atdocs:check:apibecausesite/.../methods.mdxlinks toupdate-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.
wenzhixin
left a comment
There was a problem hiding this comment.
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.tableis now registered inConstants.EVENTS(src/constants/index.js:519) with anonUpdateDetailView: (index, row, $element) => falsedefault (:341), matching theexpand-row/collapse-rowpattern. The signature matches the runtime callthis.trigger('update-detail-view', index, row, $element)(src/modules/detail.js:96). Documented inevents.mdx(en + zh-cn), which also unblocksdocs:check:api(examples #592 is merged). - Test hardening: the
triggermock intests/modules/detail.test.jsnow resolves the handler throughConstants.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
onUpdateDetailViewdefault was not propagated to the generated type artifacts. CI fails attypes:checkbecause regenerating produces drift (index.d.tsmissing'update-detail-view.bs.table': stringinBootstrapTableEventsandonUpdateDetailView?: FunctioninBootstrapTableOptions;tests/types/generated-options.test.tsmissing theonUpdateDetailViewself-assignment). I reproduced this locally by runningnode tools/create-d-ts.js— it adds exactly those 3 lines. Please runyarn types:buildand commit the updatedindex.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.jslocally: 5/5 pass, including the reworkedtriggermock path. - Ran
node tools/create-d-ts.jslocally: 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/testcurrently red attypes:check;Test/changesgreen.
Remaining notes (non-blocking)
- Column-level
detailFormatter(viaheader.detailFormatters) is still ignored byupdateDetailView— it always uses the globalthis.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.
661d010 to
e67715f
Compare
wenzhixin
left a comment
There was a problem hiding this comment.
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:buildand committed the regenerated artifacts:index.d.tsnow includes'update-detail-view.bs.table': string(BootstrapTableEvents) andonUpdateDetailView?: Function(BootstrapTableOptions), andtests/types/generated-options.test.tsincludes theonUpdateDetailViewself-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.json 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 anddeclare globalblock unchanged. npx vitest run tests/modules/detail.test.js: 5/5 passing.- Confirmed the en/zh
events.mdxdocumentation declaresonUpdateDetailViewwith parametersindex, row, $element, matching the runtime trigger call. - CI:
Test/changesandTest/testboth green one67715fb(thetypes:checkdrift gate is included in the test job). Static review plus the module test suite; no other CI run locally.
Remaining notes (non-blocking)
onUpdateDetailViewis typed as bareFunction(same style asonVirtualScrolland other handlers without atype-overrides.jsentry), so TS users don't get parameter checking for(index, row, $element). Adding a precise override intools/type-overrides.js— likeonExpandRowalready has — would be a nice follow-up.- The round-1 suggestion about
updateDetailViewonly using the globaloptions.detailFormatter(ignoring column-levelcolumn.detailFormattervia_columnDetailFormatter) remains unaddressed; acceptable as a documented limitation or follow-up.
Recommendation: good to merge.
e67715f to
57f8fdf
Compare
|
两条 non-blocking notes 已在 57f8fdf 中处理:
验证: |
wenzhixin
left a comment
There was a problem hiding this comment.
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.jsnow typesonUpdateDetailViewas(index: number, row: any, $element: JQuery<HTMLElement>) => boolean | void, and the regeneratedindex.d.tscarries the same signature, matching the runtimetrigger('update-detail-view', index, row, $element)call (src/modules/detail.js:97). - Column-level detail formatter:
updateDetailViewaccepts an optional_columnDetailFormattersecond parameter and falls back tothis.options.detailFormatter— mirroringexpandRow(src/modules/detail.js:32vs: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 globalblock 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 sitesrc/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), andupdateDetailViewByUniqueIdnot forwarding a formatter matches theexpandRowByUniqueIdconvention. The_columnDetailFormatterparam is intentionally undocumented, consistent with howtoggleDetailViewdocuments onlyindex. - CI
Test/changes+Test/testgreen (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.
🤔Type of Request
🔗Resolves an issue?
Fix #6850
Refs #6243
📝Changelog
updateDetailViewandupdateDetailViewByUniqueIdmethods to refresh an expanded detail view after the underlying data is updated (implements the approach proposed in Detail view formatter not called when table data is updated #6850).Previously, the detail view content was a snapshot rendered when the row was expanded:
updateCell/updateCellByUniqueIddid not touch it, andinitBodypreserved the old detail DOM as-is. The new methods re-rundetailFormatteron the expanded row (silently ignored if the row is not expanded) and trigger anupdate-detail-viewevent (index, row, $element), consistent with the existingexpand-row/collapse-rowevent-only style.Unit tests added in
tests/modules/detail.test.js(expanded/not-expanded/unknown-id cases); all 557 tests pass.💡Example(s)?
developbecause the original issue example was lost. Expand "Item 3", clickupdateCellByUniqueId: the row updates but the expanded detail view keeps the old value, andupdateDetailViewByUniqueIdis not available yet.661d0102onfeature/6850. Repeat the steps, then clickupdateDetailViewByUniqueId: the detail view re-renders to the new value and theupdate-detail-viewevent fires.☑️Self Check before Merge