mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix bug when dispatching unique and non-unique events of the same type on the same target (#50988)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ab543d1ab1
commit
030ca3c543
+12
-5
@@ -497,12 +497,19 @@ describe('Fantom', () => {
|
||||
const element = ensureInstance(ref.current, ReactNativeElement);
|
||||
|
||||
Fantom.runOnUIThread(() => {
|
||||
Fantom.enqueueNativeEvent(element, 'scroll', {
|
||||
contentOffset: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
Fantom.enqueueNativeEvent(
|
||||
element,
|
||||
'scroll',
|
||||
{
|
||||
contentOffset: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
{
|
||||
isUnique: true,
|
||||
},
|
||||
);
|
||||
Fantom.enqueueNativeEvent(
|
||||
element,
|
||||
'scroll',
|
||||
|
||||
+12
-5
@@ -83,12 +83,19 @@ describe('onScroll', () => {
|
||||
const element = ensureInstance(scrollViewRef.current, ReactNativeElement);
|
||||
|
||||
Fantom.runOnUIThread(() => {
|
||||
Fantom.enqueueNativeEvent(element, 'scroll', {
|
||||
contentOffset: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
Fantom.enqueueNativeEvent(
|
||||
element,
|
||||
'scroll',
|
||||
{
|
||||
contentOffset: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
{
|
||||
isUnique: true,
|
||||
},
|
||||
);
|
||||
Fantom.enqueueNativeEvent(
|
||||
element,
|
||||
'scroll',
|
||||
|
||||
@@ -35,7 +35,7 @@ void EventQueue::enqueueEvent(RawEvent&& rawEvent) const {
|
||||
|
||||
for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) {
|
||||
if (it->type == rawEvent.type &&
|
||||
it->eventTarget == rawEvent.eventTarget) {
|
||||
it->eventTarget == rawEvent.eventTarget && it->isUnique) {
|
||||
repeatedEvent = it;
|
||||
break;
|
||||
} else if (it->eventTarget == rawEvent.eventTarget) {
|
||||
|
||||
+1
-1
@@ -483,7 +483,7 @@ describe('Event Dispatching', () => {
|
||||
expect(onPointerMove).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it.skip('are NOT combined with the same type if it is non-unique', () => {
|
||||
it('are NOT combined with the same type if it is non-unique', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
const ref = React.createRef<React.ElementRef<typeof View>>();
|
||||
|
||||
Reference in New Issue
Block a user