Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ const bubblingEventTypes = {
bubbled: 'onPointerOver',
},
},
topGotPointerCapture: {
phasedRegistrationNames: {
captured: 'onGotPointerCaptureCapture',
bubbled: 'onGotPointerCapture',
},
},
topLostPointerCapture: {
phasedRegistrationNames: {
captured: 'onLostPointerCaptureCapture',
bubbled: 'onLostPointerCapture',
},
},
topClick: {
phasedRegistrationNames: {
captured: 'onClickCapture',
Expand Down Expand Up @@ -424,6 +436,10 @@ const validAttributesForEventProps = {
onPointerOutCapture: true,
onPointerOver: true,
onPointerOverCapture: true,
onGotPointerCapture: true,
onGotPointerCaptureCapture: true,
onLostPointerCapture: true,
onLostPointerCaptureCapture: true,
} as const;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,58 @@ describe('Event Dispatching', () => {
expect(onPointerUpPriority).toBe(UIManager.unstable_DiscreteEventPriority);
});

it('dispatches pointer capture events', () => {
const root = Fantom.createRoot();

const ref = React.createRef<React.ElementRef<typeof View>>();
const order: Array<string> = [];

Fantom.runTask(() => {
root.render(
<View
ref={ref}
onGotPointerCaptureCapture={() => {
order.push('got-capture');
}}
onGotPointerCapture={() => {
order.push('got-bubble');
}}
onLostPointerCaptureCapture={() => {
order.push('lost-capture');
}}
onLostPointerCapture={() => {
order.push('lost-bubble');
}}
/>,
);
});

Fantom.dispatchNativeEvent(
ref,
'onGotPointerCapture',
{pointerId: 1},
{
category: Fantom.NativeEventCategory.Discrete,
},
);

Fantom.dispatchNativeEvent(
ref,
'onLostPointerCapture',
{pointerId: 1},
{
category: Fantom.NativeEventCategory.Discrete,
},
);

expect(order).toEqual([
'got-capture',
'got-bubble',
'lost-capture',
'lost-bubble',
]);
});

it('dispatches events with continuous priority', () => {
const root = Fantom.createRoot();

Expand Down
Loading