fix(image-viewer): update trigger prop to accept index parameter#3827
Merged
Conversation
Contributor
5a4316c to
45a6074
Compare
commit: |
45a6074 to
bab27f1
Compare
Contributor
There was a problem hiding this comment.
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) => voidfor the open function - Removes
defaultIndexprop 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.
uyarn
approved these changes
Sep 30, 2025
Merged
16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🤔 这个 PR 的性质是?
🔗 相关 Issue
from TDesignOteam/tdesign-api#686
💡 需求背景和解决方案
📝 更新日志
feat(ImageViewer): 支持
trigger传入图片index参数,trigger 的open方法参数可能与绑定的元素触发事件存在类型差异情况,若遇到此问题请改成()=> open()类似匿名函数使用本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单