Skip to content

fix(image-viewer): update trigger prop to accept index parameter#3827

Merged
uyarn merged 1 commit into
Tencent:developfrom
betavs:hotfix/image-viewer-trigger
Sep 30, 2025
Merged

fix(image-viewer): update trigger prop to accept index parameter#3827
uyarn merged 1 commit into
Tencent:developfrom
betavs:hotfix/image-viewer-trigger

Conversation

@betavs

@betavs betavs commented Sep 20, 2025

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

from TDesignOteam/tdesign-api#686

💡 需求背景和解决方案

📝 更新日志

  • feat(ImageViewer): 支持 trigger 传入图片 index 参数,trigger 的 open 方法参数可能与绑定的元素触发事件存在类型差异情况,若遇到此问题请改成 ()=> open() 类似匿名函数使用

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@github-actions

github-actions Bot commented Sep 20, 2025

Copy link
Copy Markdown
Contributor

完成

@betavs betavs force-pushed the hotfix/image-viewer-trigger branch from 5a4316c to 45a6074 Compare September 20, 2025 14:44
@pkg-pr-new

pkg-pr-new Bot commented Sep 20, 2025

Copy link
Copy Markdown

tdesign-react-demo

npm i https://pkg.pr.new/tdesign-react@3827

commit: bab27f1

@betavs betavs marked this pull request as draft September 22, 2025 17:18
@betavs betavs force-pushed the hotfix/image-viewer-trigger branch from 45a6074 to bab27f1 Compare September 26, 2025 16:00
@betavs betavs marked this pull request as ready for review September 26, 2025 16:05
@RylanBot RylanBot requested a review from Copilot September 27, 2025 20:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the ImageViewer component's trigger prop to accept an optional index parameter in the open function, allowing developers to specify which image should be displayed when opening the viewer.

  • Updates the trigger prop type definition to accept (index?: number) => void for the open function
  • Removes defaultIndex prop usage in examples and uses the new index parameter instead
  • Updates all example components and tests to use arrow functions when calling open()

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
type.ts Updates trigger prop type to accept optional index parameter
image-viewer.md Updates documentation for new trigger type signature
image-viewer.en-US.md Updates English documentation for new trigger type signature
ImageViewer.tsx Implements index parameter handling in open function and uses useIndex hook
ImageViewerModal.tsx Updates index change handling and adds 'current' trigger context
_example/*.tsx Updates all examples to use arrow functions and index parameter
tests/image-viewer.test.tsx Updates test cases to use arrow functions for open calls
upload/themes/DraggerFile.tsx Updates to use arrow function for open call

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/components/image-viewer/_example/multiple.tsx
Comment thread packages/components/image-viewer/_example/error.tsx
@uyarn uyarn merged commit 7d3ad95 into Tencent:develop Sep 30, 2025
8 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 1, 2025
16 tasks
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.

3 participants