carbon-react 104.54.1 → 104.54.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.
- package/esm/components/multi-action-button/multi-action-button.component.js +9 -1
- package/esm/components/split-button/split-button.component.js +10 -2
- package/lib/components/multi-action-button/multi-action-button.component.js +10 -1
- package/lib/components/split-button/split-button.component.js +11 -2
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import Button, { ButtonWithForwardRef } from "../button";
|
|
|
8
8
|
import Events from "../../__internal__/utils/helpers/events";
|
|
9
9
|
import Popover from "../../__internal__/popover";
|
|
10
10
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
11
|
+
import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
|
|
11
12
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
12
13
|
|
|
13
14
|
const MultiActionButton = ({
|
|
@@ -22,6 +23,7 @@ const MultiActionButton = ({
|
|
|
22
23
|
...rest
|
|
23
24
|
}) => {
|
|
24
25
|
const ref = useRef();
|
|
26
|
+
const buttonRef = useRef();
|
|
25
27
|
const buttonContainer = useRef();
|
|
26
28
|
const userInputType = "ontouchstart" in document.documentElement ? "touchstart" : "click";
|
|
27
29
|
const buttonChildren = React.Children.toArray(children);
|
|
@@ -74,7 +76,12 @@ const MultiActionButton = ({
|
|
|
74
76
|
nextIndex = currentIndex < children.length - 1 ? currentIndex + 1 : 0;
|
|
75
77
|
ev.preventDefault();
|
|
76
78
|
} else if (Events.isTabKey(ev)) {
|
|
77
|
-
|
|
79
|
+
var _elements$indexOf;
|
|
80
|
+
|
|
81
|
+
const elements = Array.from(document.querySelectorAll(defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
|
|
82
|
+
const indexOf = elements.indexOf(buttonRef.current);
|
|
83
|
+
(_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
|
|
84
|
+
|
|
78
85
|
setTimeout(hideButtons, 0);
|
|
79
86
|
}
|
|
80
87
|
|
|
@@ -182,6 +189,7 @@ const MultiActionButton = ({
|
|
|
182
189
|
key: "toggle-button",
|
|
183
190
|
onKeyDown: handleMainButtonKeyDown
|
|
184
191
|
}, mainButtonProps(), {
|
|
192
|
+
forwardRef: buttonRef,
|
|
185
193
|
iconPosition: "after",
|
|
186
194
|
iconType: "dropdown"
|
|
187
195
|
}), text), showAdditionalButtons && renderAdditionalButtons());
|
|
@@ -14,6 +14,7 @@ import guid from "../../__internal__/utils/helpers/guid";
|
|
|
14
14
|
import Popover from "../../__internal__/popover";
|
|
15
15
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
16
16
|
import { baseTheme } from "../../style/themes";
|
|
17
|
+
import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
|
|
17
18
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
18
19
|
const CONTENT_WIDTH_RATIO = 0.75;
|
|
19
20
|
|
|
@@ -36,6 +37,7 @@ const SplitButton = ({
|
|
|
36
37
|
const buttonLabelId = useRef(guid());
|
|
37
38
|
const additionalButtons = useRef([]);
|
|
38
39
|
const splitButtonNode = useRef();
|
|
40
|
+
const toggleButton = useRef();
|
|
39
41
|
const buttonContainer = useRef();
|
|
40
42
|
const [showAdditionalButtons, setShowAdditionalButtons] = useState(false);
|
|
41
43
|
const [minWidth, setMinWidth] = useState(0);
|
|
@@ -69,7 +71,12 @@ const SplitButton = ({
|
|
|
69
71
|
nextIndex = currentIndex < numOfChildren ? currentIndex + 1 : 0;
|
|
70
72
|
ev.preventDefault();
|
|
71
73
|
} else if (Events.isTabKey(ev)) {
|
|
72
|
-
|
|
74
|
+
var _elements$indexOf;
|
|
75
|
+
|
|
76
|
+
const elements = Array.from(document.querySelectorAll(defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
|
|
77
|
+
const indexOf = elements.indexOf(toggleButton.current);
|
|
78
|
+
(_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
|
|
79
|
+
|
|
73
80
|
setTimeout(hideButtons, 0);
|
|
74
81
|
}
|
|
75
82
|
|
|
@@ -156,7 +163,8 @@ const SplitButton = ({
|
|
|
156
163
|
"aria-label": "Show more",
|
|
157
164
|
"data-element": "toggle-button",
|
|
158
165
|
key: "toggle-button",
|
|
159
|
-
type: "button"
|
|
166
|
+
type: "button",
|
|
167
|
+
ref: toggleButton
|
|
160
168
|
}, toggleButtonProps()), /*#__PURE__*/React.createElement(Icon, {
|
|
161
169
|
type: "dropdown",
|
|
162
170
|
bgSize: "extra-small",
|
|
@@ -21,6 +21,8 @@ var _popover = _interopRequireDefault(require("../../__internal__/popover"));
|
|
|
21
21
|
|
|
22
22
|
var _utils = require("../../style/utils");
|
|
23
23
|
|
|
24
|
+
var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
|
|
25
|
+
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
27
|
|
|
26
28
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -43,6 +45,7 @@ const MultiActionButton = ({
|
|
|
43
45
|
...rest
|
|
44
46
|
}) => {
|
|
45
47
|
const ref = (0, _react.useRef)();
|
|
48
|
+
const buttonRef = (0, _react.useRef)();
|
|
46
49
|
const buttonContainer = (0, _react.useRef)();
|
|
47
50
|
const userInputType = "ontouchstart" in document.documentElement ? "touchstart" : "click";
|
|
48
51
|
|
|
@@ -97,7 +100,12 @@ const MultiActionButton = ({
|
|
|
97
100
|
nextIndex = currentIndex < children.length - 1 ? currentIndex + 1 : 0;
|
|
98
101
|
ev.preventDefault();
|
|
99
102
|
} else if (_events.default.isTabKey(ev)) {
|
|
100
|
-
|
|
103
|
+
var _elements$indexOf;
|
|
104
|
+
|
|
105
|
+
const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
|
|
106
|
+
const indexOf = elements.indexOf(buttonRef.current);
|
|
107
|
+
(_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
|
|
108
|
+
|
|
101
109
|
setTimeout(hideButtons, 0);
|
|
102
110
|
}
|
|
103
111
|
|
|
@@ -205,6 +213,7 @@ const MultiActionButton = ({
|
|
|
205
213
|
key: "toggle-button",
|
|
206
214
|
onKeyDown: handleMainButtonKeyDown
|
|
207
215
|
}, mainButtonProps(), {
|
|
216
|
+
forwardRef: buttonRef,
|
|
208
217
|
iconPosition: "after",
|
|
209
218
|
iconType: "dropdown"
|
|
210
219
|
}), text), showAdditionalButtons && renderAdditionalButtons());
|
|
@@ -33,6 +33,8 @@ var _utils = require("../../style/utils");
|
|
|
33
33
|
|
|
34
34
|
var _themes = require("../../style/themes");
|
|
35
35
|
|
|
36
|
+
var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
|
|
37
|
+
|
|
36
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
39
|
|
|
38
40
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -64,6 +66,7 @@ const SplitButton = ({
|
|
|
64
66
|
const buttonLabelId = (0, _react.useRef)((0, _guid.default)());
|
|
65
67
|
const additionalButtons = (0, _react.useRef)([]);
|
|
66
68
|
const splitButtonNode = (0, _react.useRef)();
|
|
69
|
+
const toggleButton = (0, _react.useRef)();
|
|
67
70
|
const buttonContainer = (0, _react.useRef)();
|
|
68
71
|
const [showAdditionalButtons, setShowAdditionalButtons] = (0, _react.useState)(false);
|
|
69
72
|
const [minWidth, setMinWidth] = (0, _react.useState)(0);
|
|
@@ -97,7 +100,12 @@ const SplitButton = ({
|
|
|
97
100
|
nextIndex = currentIndex < numOfChildren ? currentIndex + 1 : 0;
|
|
98
101
|
ev.preventDefault();
|
|
99
102
|
} else if (_events.default.isTabKey(ev)) {
|
|
100
|
-
|
|
103
|
+
var _elements$indexOf;
|
|
104
|
+
|
|
105
|
+
const elements = Array.from(document.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
|
|
106
|
+
const indexOf = elements.indexOf(toggleButton.current);
|
|
107
|
+
(_elements$indexOf = elements[indexOf]) === null || _elements$indexOf === void 0 ? void 0 : _elements$indexOf.focus(); // timeout enforces that the "hideButtons" method will be run after browser focuses on the next element
|
|
108
|
+
|
|
101
109
|
setTimeout(hideButtons, 0);
|
|
102
110
|
}
|
|
103
111
|
|
|
@@ -184,7 +192,8 @@ const SplitButton = ({
|
|
|
184
192
|
"aria-label": "Show more",
|
|
185
193
|
"data-element": "toggle-button",
|
|
186
194
|
key: "toggle-button",
|
|
187
|
-
type: "button"
|
|
195
|
+
type: "button",
|
|
196
|
+
ref: toggleButton
|
|
188
197
|
}, toggleButtonProps()), /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
189
198
|
type: "dropdown",
|
|
190
199
|
bgSize: "extra-small",
|