vira 31.9.0 → 31.9.1
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.
|
@@ -122,12 +122,25 @@ export const ViraMenuItem = defineViraElement()({
|
|
|
122
122
|
event.stopPropagation();
|
|
123
123
|
propagating[event.type] = true;
|
|
124
124
|
if (event.type === 'click') {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
const hasModifiers = event instanceof MouseEvent &&
|
|
126
|
+
(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey);
|
|
127
|
+
if (hasModifiers) {
|
|
128
|
+
/**
|
|
129
|
+
* If modifier keys are present, dispatch a synthetic MouseEvent so
|
|
130
|
+
* that the modifier keys are preserved. This is needed so that
|
|
131
|
+
* cmd+click opens links in a new tab.
|
|
132
|
+
*/
|
|
133
|
+
element.dispatchEvent(new MouseEvent('click', event));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
/**
|
|
137
|
+
* Use `.click()` instead of dispatching a synthetic MouseEvent so
|
|
138
|
+
* that the resulting event is trusted and carries user activation.
|
|
139
|
+
* This is required for APIs like `showPicker()` on `<select>`
|
|
140
|
+
* elements.
|
|
141
|
+
*/
|
|
142
|
+
element.click();
|
|
143
|
+
}
|
|
131
144
|
}
|
|
132
145
|
else {
|
|
133
146
|
element.dispatchEvent(new MouseEvent(event.type, event));
|