carbon-react 115.0.0 → 115.0.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.
- package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +2 -6
- package/esm/components/action-popover/action-popover.component.js +9 -0
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -6
- package/lib/components/action-popover/action-popover.component.js +10 -0
- package/package.json +1 -1
|
@@ -129,11 +129,7 @@ const ActionPopoverItem = ({
|
|
|
129
129
|
}
|
|
130
130
|
}, [disabled, focusButton, onClickProp, setOpenPopover]);
|
|
131
131
|
const onKeyDown = useCallback(e => {
|
|
132
|
-
if (Events.
|
|
133
|
-
e.stopPropagation();
|
|
134
|
-
setOpenPopover(false);
|
|
135
|
-
focusButton();
|
|
136
|
-
} else if (Events.isSpaceKey(e)) {
|
|
132
|
+
if (Events.isSpaceKey(e)) {
|
|
137
133
|
e.preventDefault();
|
|
138
134
|
e.stopPropagation();
|
|
139
135
|
} else if (!disabled) {
|
|
@@ -182,7 +178,7 @@ const ActionPopoverItem = ({
|
|
|
182
178
|
} else if (Events.isEnterKey(e)) {
|
|
183
179
|
e.stopPropagation();
|
|
184
180
|
}
|
|
185
|
-
}, [disabled, download,
|
|
181
|
+
}, [disabled, download, isHref, isLeftAligned, onClick, submenu]);
|
|
186
182
|
const itemSubmenuProps = { ...(!disabled && {
|
|
187
183
|
onMouseEnter: e => {
|
|
188
184
|
if (mouseEnterTimer.current) clearTimeout(mouseEnterTimer.current);
|
|
@@ -12,6 +12,7 @@ import ActionPopoverMenu from "./action-popover-menu/action-popover-menu.compone
|
|
|
12
12
|
import ActionPopoverItem from "./action-popover-item/action-popover-item.component";
|
|
13
13
|
import ActionPopoverDivider from "./action-popover-divider/action-popover-divider.component";
|
|
14
14
|
import ActionPopoverContext from "./action-popover-context";
|
|
15
|
+
import useModalManager from "../../hooks/__internal__/useModalManager";
|
|
15
16
|
|
|
16
17
|
const onOpenDefault = () => {};
|
|
17
18
|
|
|
@@ -107,6 +108,14 @@ const ActionPopover = ({
|
|
|
107
108
|
setOpen(true);
|
|
108
109
|
}
|
|
109
110
|
}, [itemCount, setOpen]);
|
|
111
|
+
const handleEscapeKey = useCallback(e => {
|
|
112
|
+
/* istanbul ignore else */
|
|
113
|
+
if (Events.isEscKey(e)) {
|
|
114
|
+
setOpen(false);
|
|
115
|
+
focusButton();
|
|
116
|
+
}
|
|
117
|
+
}, [setOpen, focusButton]);
|
|
118
|
+
useModalManager(isOpen, handleEscapeKey, buttonRef);
|
|
110
119
|
useEffect(() => {
|
|
111
120
|
const handler = ({
|
|
112
121
|
target
|
|
@@ -151,11 +151,7 @@ const ActionPopoverItem = ({
|
|
|
151
151
|
}
|
|
152
152
|
}, [disabled, focusButton, onClickProp, setOpenPopover]);
|
|
153
153
|
const onKeyDown = (0, _react.useCallback)(e => {
|
|
154
|
-
if (_events.default.
|
|
155
|
-
e.stopPropagation();
|
|
156
|
-
setOpenPopover(false);
|
|
157
|
-
focusButton();
|
|
158
|
-
} else if (_events.default.isSpaceKey(e)) {
|
|
154
|
+
if (_events.default.isSpaceKey(e)) {
|
|
159
155
|
e.preventDefault();
|
|
160
156
|
e.stopPropagation();
|
|
161
157
|
} else if (!disabled) {
|
|
@@ -204,7 +200,7 @@ const ActionPopoverItem = ({
|
|
|
204
200
|
} else if (_events.default.isEnterKey(e)) {
|
|
205
201
|
e.stopPropagation();
|
|
206
202
|
}
|
|
207
|
-
}, [disabled, download,
|
|
203
|
+
}, [disabled, download, isHref, isLeftAligned, onClick, submenu]);
|
|
208
204
|
const itemSubmenuProps = { ...(!disabled && {
|
|
209
205
|
onMouseEnter: e => {
|
|
210
206
|
if (mouseEnterTimer.current) clearTimeout(mouseEnterTimer.current);
|
|
@@ -29,6 +29,8 @@ var _actionPopoverDivider = _interopRequireDefault(require("./action-popover-div
|
|
|
29
29
|
|
|
30
30
|
var _actionPopoverContext = _interopRequireDefault(require("./action-popover-context"));
|
|
31
31
|
|
|
32
|
+
var _useModalManager = _interopRequireDefault(require("../../hooks/__internal__/useModalManager"));
|
|
33
|
+
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
35
|
|
|
34
36
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -132,6 +134,14 @@ const ActionPopover = ({
|
|
|
132
134
|
setOpen(true);
|
|
133
135
|
}
|
|
134
136
|
}, [itemCount, setOpen]);
|
|
137
|
+
const handleEscapeKey = (0, _react.useCallback)(e => {
|
|
138
|
+
/* istanbul ignore else */
|
|
139
|
+
if (_events.default.isEscKey(e)) {
|
|
140
|
+
setOpen(false);
|
|
141
|
+
focusButton();
|
|
142
|
+
}
|
|
143
|
+
}, [setOpen, focusButton]);
|
|
144
|
+
(0, _useModalManager.default)(isOpen, handleEscapeKey, buttonRef);
|
|
135
145
|
(0, _react.useEffect)(() => {
|
|
136
146
|
const handler = ({
|
|
137
147
|
target
|