@homecode/ui 5.20.1 → 5.20.2
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.
|
@@ -82,15 +82,27 @@ function NestedMenuComponent({ trigger, items, open, onOpenChange, align = 'end'
|
|
|
82
82
|
}
|
|
83
83
|
function renderItemButton(item) {
|
|
84
84
|
return (jsxs("button", { type: "button", className: cn(S.item, activeId === item.id && S.itemActive, item.danger && S.itemDanger, item.disabled && S.itemDisabled, item.wrap && S.wrap, item.className), role: "menuitem", disabled: item.disabled, "aria-haspopup": item.submenu ? 'menu' : undefined, "aria-expanded": item.submenu ? activeId === item.id : undefined, onPointerDown: e => {
|
|
85
|
+
// Touch/pen are handled on click: acting on pointerdown opens a
|
|
86
|
+
// Dialog under the finger, and the synthesized click then lands on
|
|
87
|
+
// its overlay and closes it immediately.
|
|
88
|
+
if (e.button === 0 && e.pointerType === 'mouse') {
|
|
89
|
+
handleItemClick(item.id, e);
|
|
90
|
+
}
|
|
85
91
|
// Keep focus off underlying inputs (e.g. ChatSelector search).
|
|
92
|
+
// After the handler: it reads `defaultPrevented` to let an item's
|
|
93
|
+
// onClick keep the menu open.
|
|
86
94
|
e.preventDefault();
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
}, onClick: e => {
|
|
96
|
+
// Mouse is handled on pointerdown; keyboard on keydown (detail 0).
|
|
97
|
+
const { pointerType } = e.nativeEvent;
|
|
98
|
+
if (e.detail === 0 || pointerType === 'mouse')
|
|
99
|
+
return;
|
|
100
|
+
handleItemClick(item.id, e);
|
|
89
101
|
}, onKeyDown: e => {
|
|
90
102
|
if (e.key !== 'Enter' && e.key !== ' ')
|
|
91
103
|
return;
|
|
92
|
-
e.preventDefault();
|
|
93
104
|
handleItemClick(item.id, e);
|
|
105
|
+
e.preventDefault();
|
|
94
106
|
}, children: [item.icon && (jsx("span", { className: S.icon, "aria-hidden": true, children: item.icon })), item.hint != null && item.hint !== '' ? (jsxs("span", { className: S.text, children: [jsx("span", { className: S.label, children: item.label }), jsx("span", { className: S.hint, children: item.hint })] })) : (jsx("span", { className: S.label, children: item.label })), item.submenu && (jsx(Icon, { className: S.chevron, type: "chevronRight", size: iconSize }))] }));
|
|
95
107
|
}
|
|
96
108
|
function renderItems() {
|