Skip to content

Commit 8f589ba

Browse files
Fix simulated context menu events not being mouse events
1 parent 60f8eda commit 8f589ba

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

lib/src/react_client/event_helpers.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ extension SyntheticEventTypeHelpers on SyntheticEvent {
783783
(_hasProperty('relatedTarget') && !_hasProperty('button')) || _checkEventType(const ['focus', 'blur']);
784784

785785
/// Uses Duck Typing to detect if the event instance is a [SyntheticMouseEvent].
786-
bool get isMouseEvent => _hasProperty('button') || _checkEventType(const ['mouse', 'click', 'drag', 'drop']);
786+
bool get isMouseEvent =>
787+
_hasProperty('button') || _checkEventType(const ['mouse', 'click', 'drag', 'drop', 'contextmenu']);
787788

788789
/// Uses Duck Typing to detect if the event instance is a [SyntheticPointerEvent].
789790
bool get isPointerEvent => _hasProperty('pointerId') || _checkEventType(const ['pointer']);

test/react_test_utils_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ testUtils({isComponent2: false, dynamic eventComponent, dynamic sampleComponent,
158158
group('compositionStart', () => testEvent(Simulate.compositionStart, 'compositionStart', expectCompositionEvent));
159159
group('compositionUpdate',
160160
() => testEvent(Simulate.compositionUpdate, 'compositionUpdate', expectCompositionEvent));
161+
group('contextMenu',
162+
() => testEvent(Simulate.contextMenu, 'contextMenu', expectMouseEvent));
161163
group('cut', () => testEvent(Simulate.cut, 'cut', expectClipboardEvent));
162164
group('doubleClick', () => testEvent(Simulate.doubleClick, 'doubleClick', expectMouseEvent));
163165
group('drag', () => testEvent(Simulate.drag, 'drag', expectMouseEvent));

test/test_components.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class EventComponent extends Component {
1616
'onCompositionEnd': onEvent,
1717
'onCompositionStart': onEvent,
1818
'onCompositionUpdate': onEvent,
19+
'onContextMenu': onEvent,
1920
'onCut': onEvent,
2021
'onDoubleClick': onEvent,
2122
'onDrag': onEvent,

test/test_components2.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class EventComponent2 extends Component2 {
1616
'onCompositionEnd': onEvent,
1717
'onCompositionStart': onEvent,
1818
'onCompositionUpdate': onEvent,
19+
'onContextMenu': onEvent,
1920
'onCut': onEvent,
2021
'onDoubleClick': onEvent,
2122
'onDrag': onEvent,

0 commit comments

Comments
 (0)