[Bug] headerCustomRender 类型为 ract作为触发事件的target时无法通过target.attribute获取到elementKey, 类型为text的element可以获取
Open
Nobody has claimed this yet.
bug
- Dominant language
- TypeScript
- Stars
- 3.7k
- Forks
- 486
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 16
Description
Version
1.19.3
Link to Minimal Reproduction
1.19.3
Steps to Reproduce
在实现树表格支持按层级展开收缩的需求
层级按钮代码如下:
headerCustomRender: {
renderDefault: true,
elements: Array.from({ length: maxLevel }).reduce((els, _, i) => {
const no = i + 1;
els.push({
type: 'rect',
elementKey: `level-tag-react-${no}`,
x: 140 + 26 * i,
fill: '#468aff',
stroke: '#468aff',
radius: 2,
width: 20,
height: 20,
y: (50 - 24) / 2,
// cursor: 'pointer',
// pickable: true,
});
els.push({
type: 'text',
elementKey: `level-tag-text-${no}`,
text: no,
x: 140 + 26 * i,
fill: 'white',
stroke: 'white',
fontSize: 14,
fontWeight: 6,
fontFamily:
'-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol',
y: 50 - (50 - 8) / 2,
dx: 6,
dy: 0,
// cursor: 'pointer',
// pickable: true,
});
els.push({
type: 'rect',
elementKey: `level-tag-pick-${no}`,
x: 140 + 26 * i,
fill: '',
stroke: '',
width: 20,
height: 20,
y: (50 - 24) / 2,
cursor: 'pointer',
pickable: true,
});
return els;
}, []),
然后通过监听事件获取
调试发现类型为rect 的element 缺失 elementKey 属性
Current Behavior
是否是个问题?
Expected Behavior
是否是个问题?
Environment
- OS:
- Browser:
- Framework:
Any additional comments?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied headerCustomRender minimal reproduction and trace the event target for the rect and text elements. Compare how each element exposes elementKey, then verify that the intended target element key is available consistently when the event is handled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100