Skip to content

Commit 030ca3c

Browse files
rubennortefacebook-github-bot
authored andcommitted
Fix bug when dispatching unique and non-unique events of the same type on the same target (#50988)
Summary: Pull Request resolved: #50988 Changelog: [internal] This fixes a potential bug where we coalesce unique events with non-unique ones of the same type and target. Not marked as a bug fix in the changelog because this wouldn't happen in practice, as we always dispatch events of a given type the same way (all unique or all non-unique). Reviewed By: sammy-SC, javache Differential Revision: D73849222 fbshipit-source-id: 6f387d63b3a68dccc81c110287d42e15e31c181e
1 parent ab543d1 commit 030ca3c

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

‎packages/react-native-fantom/src/__tests__/Fantom-itest.js‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,19 @@ describe('Fantom', () => {
497497
const element = ensureInstance(ref.current, ReactNativeElement);
498498

499499
Fantom.runOnUIThread(() => {
500-
Fantom.enqueueNativeEvent(element, 'scroll', {
501-
contentOffset: {
502-
x: 0,
503-
y: 1,
500+
Fantom.enqueueNativeEvent(
501+
element,
502+
'scroll',
503+
{
504+
contentOffset: {
505+
x: 0,
506+
y: 1,
507+
},
504508
},
505-
});
509+
{
510+
isUnique: true,
511+
},
512+
);
506513
Fantom.enqueueNativeEvent(
507514
element,
508515
'scroll',

‎packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-itest.js‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,19 @@ describe('onScroll', () => {
8383
const element = ensureInstance(scrollViewRef.current, ReactNativeElement);
8484

8585
Fantom.runOnUIThread(() => {
86-
Fantom.enqueueNativeEvent(element, 'scroll', {
87-
contentOffset: {
88-
x: 0,
89-
y: 1,
86+
Fantom.enqueueNativeEvent(
87+
element,
88+
'scroll',
89+
{
90+
contentOffset: {
91+
x: 0,
92+
y: 1,
93+
},
94+
},
95+
{
96+
isUnique: true,
9097
},
91-
});
98+
);
9299
Fantom.enqueueNativeEvent(
93100
element,
94101
'scroll',

‎packages/react-native/ReactCommon/react/renderer/core/EventQueue.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void EventQueue::enqueueEvent(RawEvent&& rawEvent) const {
3535

3636
for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) {
3737
if (it->type == rawEvent.type &&
38-
it->eventTarget == rawEvent.eventTarget) {
38+
it->eventTarget == rawEvent.eventTarget && it->isUnique) {
3939
repeatedEvent = it;
4040
break;
4141
} else if (it->eventTarget == rawEvent.eventTarget) {

‎packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ describe('Event Dispatching', () => {
483483
expect(onPointerMove).toHaveBeenCalledTimes(2);
484484
});
485485

486-
it.skip('are NOT combined with the same type if it is non-unique', () => {
486+
it('are NOT combined with the same type if it is non-unique', () => {
487487
const root = Fantom.createRoot();
488488

489489
const ref = React.createRef<React.ElementRef<typeof View>>();

0 commit comments

Comments
 (0)