@topconsultnpm/sdkui-react 6.20.0-dev1.102 → 6.20.0-dev1.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -61,8 +61,6 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
61
61
|
const touchEvent = e;
|
|
62
62
|
const element = e.currentTarget;
|
|
63
63
|
const touch = touchEvent.touches[0];
|
|
64
|
-
// Prevent text selection during long press
|
|
65
|
-
e.preventDefault();
|
|
66
64
|
let state = touchStateMap.get(element);
|
|
67
65
|
if (!state) {
|
|
68
66
|
state = { timeout: null, startX: 0, startY: 0, longPressTriggered: false };
|
|
@@ -85,6 +83,8 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
85
83
|
clientX: touch.clientX,
|
|
86
84
|
clientY: touch.clientY,
|
|
87
85
|
});
|
|
86
|
+
// Mark this as our synthetic event
|
|
87
|
+
syntheticEvent.isSynthetic = true;
|
|
88
88
|
element.dispatchEvent(syntheticEvent);
|
|
89
89
|
if (state)
|
|
90
90
|
state.timeout = null;
|
|
@@ -123,8 +123,11 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
123
123
|
state.longPressTriggered = false;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
// Prevent default iOS context menu
|
|
126
|
+
// Prevent default iOS context menu (but allow our synthetic events)
|
|
127
127
|
const handleContextMenu = (e) => {
|
|
128
|
+
// Don't prevent our own synthetic contextmenu events
|
|
129
|
+
if (e.isSynthetic)
|
|
130
|
+
return;
|
|
128
131
|
e.preventDefault();
|
|
129
132
|
e.stopPropagation();
|
|
130
133
|
return false;
|
|
@@ -132,13 +135,12 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
132
135
|
// Attach listeners to all matching elements
|
|
133
136
|
elements.forEach(element => {
|
|
134
137
|
const el = element;
|
|
135
|
-
// Prevent iOS native callout and text selection
|
|
138
|
+
// Prevent iOS native callout and text selection - must be set before touch starts
|
|
136
139
|
const style = el.style;
|
|
137
140
|
style.webkitTouchCallout = 'none';
|
|
138
141
|
style.webkitUserSelect = 'none';
|
|
139
|
-
|
|
140
|
-
el.addEventListener('
|
|
141
|
-
el.addEventListener('touchmove', handleTouchMove, { passive: false });
|
|
142
|
+
el.addEventListener('touchstart', handleTouchStart, { passive: true });
|
|
143
|
+
el.addEventListener('touchmove', handleTouchMove, { passive: true });
|
|
142
144
|
el.addEventListener('touchend', handleTouchEnd);
|
|
143
145
|
el.addEventListener('touchcancel', handleTouchEnd);
|
|
144
146
|
el.addEventListener('contextmenu', handleContextMenu);
|
|
@@ -147,10 +149,10 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
147
149
|
return () => {
|
|
148
150
|
elements.forEach(element => {
|
|
149
151
|
const el = element;
|
|
152
|
+
// Restore webkit properties
|
|
150
153
|
const style = el.style;
|
|
151
154
|
style.webkitTouchCallout = '';
|
|
152
155
|
style.webkitUserSelect = '';
|
|
153
|
-
style.userSelect = '';
|
|
154
156
|
el.removeEventListener('touchstart', handleTouchStart);
|
|
155
157
|
el.removeEventListener('touchmove', handleTouchMove);
|
|
156
158
|
el.removeEventListener('touchend', handleTouchEnd);
|
|
@@ -212,9 +214,10 @@ const TMContextMenu = ({ items, trigger = 'right', children, target, externalCon
|
|
|
212
214
|
if (!menuState.visible)
|
|
213
215
|
return;
|
|
214
216
|
const handleClickOutside = (event) => {
|
|
215
|
-
// On iOS, prevent closing immediately after opening (within 300ms)
|
|
217
|
+
// On iOS, prevent closing immediately after opening (within 500ms for iOS, 300ms for others)
|
|
216
218
|
// This handles the case where touchend from long-press triggers touchstart listener
|
|
217
|
-
|
|
219
|
+
const delay = isIOS ? 500 : 300;
|
|
220
|
+
if (Date.now() - menuOpenedAtRef.current < delay) {
|
|
218
221
|
return;
|
|
219
222
|
}
|
|
220
223
|
const target = event.target;
|