Skip to content

Commit fb8da78

Browse files
committed
matrix: (1) Both cellRect (typically non-transparent) and cellText may trigger events, depending on both matrix.triggerEvent, matrix.xxx.silent and matrix.xxx.label.silent settings. By default (matrix.triggerEvent:true, matrix.xxx.silent and matrix.xxx.label.silent is undefined) cell text and non-transparent cell bg trigger event. (2) Modify event param: name is the final rendered text, value is the original input cell value in option. (3) Add visual test cases for matrix.html.
1 parent 6609e32 commit fb8da78

3 files changed

Lines changed: 42 additions & 6 deletions

File tree

src/component/matrix/MatrixView.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ function createMatrixCell(
367367
}
368368

369369
// Set silent
370-
const triggerEvent = matrixModel.get('triggerEvent');
370+
const triggerEvent = matrixModel.get('triggerEvent', true);
371371
if (cellText) {
372372
let labelSilent = _tmpCellLabelModel.get('silent');
373373
// By default, silent: false is needed for triggerEvent or tooltip interaction.
@@ -382,21 +382,26 @@ function createMatrixCell(
382382
rectSilent = (
383383
// If no background color in cell, set `rect.silent: false` will cause that only
384384
// the border response to mouse hovering, which is probably weird.
385+
// So we deliberately make rect non-interactive if `silent` is not explicitly specified,
386+
// even if `triggerEvent` is set as `true`.
385387
!cellRect.style || cellRect.style.fill === 'none' || !cellRect.style.fill
386388
);
387389
}
388390
cellRect.silent = rectSilent;
389391

390-
if (triggerEvent && cellText) {
392+
// Both `cellRect` (typically non-transparent) and `cellText` may trigger events, depending on both
393+
// `matrix.triggerEvent`, `matrix.xxx.silent` and `matrix.xxx.label.silent` settings.
394+
if (triggerEvent && cellRect) {
391395
const eventData = {
392396
componentType: 'matrix' as const,
393397
componentIndex: matrixModel.componentIndex,
394398
matrixIndex: matrixModel.componentIndex,
395399
targetType: targetType,
396-
name: textValue != null ? textValue + '' : null,
400+
name: (cellText && cellText.style) ? cellText.style.text : undefined,
401+
value: textValue,
397402
coord: xyLocator.slice()
398403
};
399-
getECData(cellText).eventData = eventData;
404+
getECData(cellRect).eventData = eventData;
400405
}
401406

402407
clearTmpModel(_tmpCellModel);

test/matrix.html

Lines changed: 32 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/runTest/actions/__meta__.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)