Skip to content

Commit

Permalink
fix(event): there is no target for pointerupoutside event (#5100)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed May 26, 2023
1 parent a1db7aa commit 641f966
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 2 additions & 5 deletions __tests__/integration/api-chart-on-item-element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,10 @@ describe('chart.on', () => {
await fired;
});

it('chart.on("interval:pointerupoutside", callback) should provide datum for item element', async () => {
it('chart.on("plot:pointerupoutside", callback) should provide datum for item element', async () => {
await finished;
const [fired, resolve] = createPromise();
chart.on(
`interval:${ChartEvent.POINTER_UPOUTSIDE}`,
receiveExpectData(resolve),
);
chart.on(`plot:${ChartEvent.POINTER_UPOUTSIDE}`, resolve);
dispatchFirstElementEvent(canvas, 'pointerupoutside');
await fired;
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/plots/api/chart-on-item-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function chartOnItemElement(context) {
chart.on('interval:pointermove', log('interval:pointermove'));
chart.on('interval:pointerenter', log('interval:pointerenter'));
chart.on('interval:pointerleave', log('interval:pointerleave'));
chart.on('interval:pointerupoutside', log('interval:pointerupoutside'));
chart.on('plot:pointerupoutside', () => console.log('plot:pointerupoutside'));

chart.on('interval:dragstart', log('interval:dragstart'));
chart.on('interval:drag', log('interval:drag'));
Expand Down
9 changes: 7 additions & 2 deletions src/interaction/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ export function dataOf(element, view) {
function bubblesEvent(eventType, view, emitter, predicate = (event) => true) {
return (e) => {
if (!predicate(e)) return;
const { target } = e;
const { className: elementType, markType } = target;

// Emit plot events.
emitter.emit(`plot:${eventType}`, e);

const { target } = e;

// There is no target for pointerupoutside event if out of canvas.
if (!target) return;

const { className: elementType, markType } = target;

// If target area is plot area, do not emit extra events.
if (elementType === 'plot') return;

Expand Down

0 comments on commit 641f966

Please sign in to comment.