Skip to content

fix(notion): 从渲染上下文读取 Gallery 视图配置 - #4370

Merged
tangly1024 merged 1 commit into
notionnext-org:mainfrom
kforris:fix/gallery-visibility-renderer-props-4334
Aug 6, 2026
Merged

fix(notion): 从渲染上下文读取 Gallery 视图配置#4370
tangly1024 merged 1 commit into
notionnext-org:mainfrom
kforris:fix/gallery-visibility-renderer-props-4334

Conversation

@kforris

@kforris kforris commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

背景

#4338 已补齐 Gallery 页面图标和 Title 可见性规则,但报告者在合并后的最新 main 上复测仍无变化。

重新沿真实渲染路径检查后发现,#4343 将第三方补丁迁移为本地 NotionCollection 包装器时,包装器读取了 props.collectionView;而 react-notion-x@7.10.0 的 Collection override 实际只传入 blockctx。因此可见性 helper 虽然测试通过,运行时却始终拿不到 Gallery 视图配置,也不会输出隐藏 class。

这是 #4334 / #4338 的后续修复。

解决方案

  • block.view_ids[0] 确定初始 Collection view;
  • ctx.recordMap.collection_view 读取并解包实际 Gallery view;
  • 继续复用现有 galleryVisibilityClassName 和 Gallery 限定样式;
  • 不恢复 patch-package,保留 docs: remove dead update guide link #4343 避免修改第三方构建产物的目标。

回归测试

新增两层契约检查:

  1. 使用真实 NotionRenderer 确认 Collection override 收到的是 blockctx,并确认 Gallery view 位于 ctx.recordMap
  2. 使用该真实属性形态渲染本地包装器,确认同时输出隐藏页面图标和隐藏 Title 的 class。

原有当前数据与旧数据兼容用例继续保留。

风险与兼容性

  • 风险等级:低。
  • 仅修改 2 个文件,不升级依赖、不修改 CSS、配置、路由或数据结构。
  • 非 Gallery Collection 仍返回空可见性 class,并沿用原渲染路径。

验证

  • yarn jest __tests__/components/NotionCollectionGallery.test.js --runInBand(6/6)
  • yarn test --runInBand(39 suites / 211 tests)
  • yarn type-check
  • yarn lint(退出码 0;仅仓库既有 warnings)
  • yarn build(61 个静态页面生成完成;仅仓库既有 warnings)
  • yarn prettier --check components/NotionCollection.js __tests__/components/NotionCollectionGallery.test.js
  • git diff --check

用户文档

  • 不适用:本次恢复现有 Gallery 配置语义,不新增配置项或部署步骤。

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

@kforris is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for notionnext-netlify ready!

Name Link
🔨 Latest commit f9e3a46
🔍 Latest deploy log https://app.netlify.com/projects/notionnext-netlify/deploys/6a71753810318100084eef3f
😎 Deploy Preview https://deploy-preview-4370--notionnext-netlify.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
notion-next-preview Ready Ready Preview Aug 6, 2026 3:46am

@tangly1024 tangly1024 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the narrow Gallery renderer-context fix and verified the targeted Jest test locally: yarn test tests/components/NotionCollectionGallery.test.js --runInBand.

@tangly1024
tangly1024 merged commit 0f7b87b into notionnext-org:main Aug 6, 2026
13 checks passed
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