@carbon/react 1.105.0-rc.0 → 1.105.0
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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +945 -945
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +4 -0
- package/es/components/Menu/Menu.js +10 -3
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +4 -0
- package/lib/components/Menu/Menu.js +10 -3
- package/package.json +7 -7
|
@@ -47,8 +47,12 @@ const fixEventsPlugin = (config) => (fp) => {
|
|
|
47
47
|
const { target } = event;
|
|
48
48
|
if (inputFrom === target || inputTo === target) {
|
|
49
49
|
if (match(event, Enter)) {
|
|
50
|
+
mouseDownInside = false;
|
|
50
51
|
fp.setDate(inputTo ? [inputFrom.value, inputTo.value] : [inputFrom.value], true, fp.config.dateFormat);
|
|
51
52
|
event.stopPropagation();
|
|
53
|
+
if (inputTo === target && fp.config.closeOnSelect) requestAnimationFrame(() => {
|
|
54
|
+
fp.close();
|
|
55
|
+
});
|
|
52
56
|
} else if (match(event, ArrowLeft) || match(event, ArrowRight)) event.stopPropagation();
|
|
53
57
|
else if (match(event, ArrowDown)) {
|
|
54
58
|
event.preventDefault();
|
|
@@ -50,7 +50,7 @@ const Menu = forwardRef(function Menu({ backgroundToken = "layer", border = fals
|
|
|
50
50
|
const menu = useRef(null);
|
|
51
51
|
const ref = useMergedRefs([forwardRef, menu]);
|
|
52
52
|
const [position, setPosition] = useState([-1, -1]);
|
|
53
|
-
const focusableItems = childContext.state.items.filter((item) => !item.disabled && item.ref.current);
|
|
53
|
+
const focusableItems = useMemo(() => childContext.state.items.filter((item) => !item.disabled && item.ref.current), [childContext.state.items]);
|
|
54
54
|
let actionButtonWidth;
|
|
55
55
|
if (containerRef?.current) {
|
|
56
56
|
const { width: w } = containerRef.current.getBoundingClientRect();
|
|
@@ -169,11 +169,18 @@ const Menu = forwardRef(function Menu({ backgroundToken = "layer", border = fals
|
|
|
169
169
|
useEffect(() => {
|
|
170
170
|
if (open) {
|
|
171
171
|
const raf = requestAnimationFrame(() => {
|
|
172
|
-
|
|
172
|
+
const activeElement = menu.current?.ownerDocument.activeElement;
|
|
173
|
+
const menuContainsFocus = activeElement instanceof Node && menu.current?.contains(activeElement);
|
|
174
|
+
if (focusableItems.length > 0 && (!isRoot || menuContainsFocus)) focusItem();
|
|
173
175
|
});
|
|
174
176
|
return () => cancelAnimationFrame(raf);
|
|
175
177
|
}
|
|
176
|
-
}, [
|
|
178
|
+
}, [
|
|
179
|
+
open,
|
|
180
|
+
focusableItems,
|
|
181
|
+
isRoot,
|
|
182
|
+
position
|
|
183
|
+
]);
|
|
177
184
|
useEffect(() => {
|
|
178
185
|
if (open) handleOpen();
|
|
179
186
|
else setPosition([-1, -1]);
|
|
@@ -47,8 +47,12 @@ const fixEventsPlugin = (config) => (fp) => {
|
|
|
47
47
|
const { target } = event;
|
|
48
48
|
if (inputFrom === target || inputTo === target) {
|
|
49
49
|
if (require_match.match(event, require_keys.Enter)) {
|
|
50
|
+
mouseDownInside = false;
|
|
50
51
|
fp.setDate(inputTo ? [inputFrom.value, inputTo.value] : [inputFrom.value], true, fp.config.dateFormat);
|
|
51
52
|
event.stopPropagation();
|
|
53
|
+
if (inputTo === target && fp.config.closeOnSelect) requestAnimationFrame(() => {
|
|
54
|
+
fp.close();
|
|
55
|
+
});
|
|
52
56
|
} else if (require_match.match(event, require_keys.ArrowLeft) || require_match.match(event, require_keys.ArrowRight)) event.stopPropagation();
|
|
53
57
|
else if (require_match.match(event, require_keys.ArrowDown)) {
|
|
54
58
|
event.preventDefault();
|
|
@@ -54,7 +54,7 @@ const Menu = (0, react.forwardRef)(function Menu({ backgroundToken = "layer", bo
|
|
|
54
54
|
const menu = (0, react.useRef)(null);
|
|
55
55
|
const ref = require_useMergedRefs.useMergedRefs([forwardRef, menu]);
|
|
56
56
|
const [position, setPosition] = (0, react.useState)([-1, -1]);
|
|
57
|
-
const focusableItems = childContext.state.items.filter((item) => !item.disabled && item.ref.current);
|
|
57
|
+
const focusableItems = (0, react.useMemo)(() => childContext.state.items.filter((item) => !item.disabled && item.ref.current), [childContext.state.items]);
|
|
58
58
|
let actionButtonWidth;
|
|
59
59
|
if (containerRef?.current) {
|
|
60
60
|
const { width: w } = containerRef.current.getBoundingClientRect();
|
|
@@ -173,11 +173,18 @@ const Menu = (0, react.forwardRef)(function Menu({ backgroundToken = "layer", bo
|
|
|
173
173
|
(0, react.useEffect)(() => {
|
|
174
174
|
if (open) {
|
|
175
175
|
const raf = requestAnimationFrame(() => {
|
|
176
|
-
|
|
176
|
+
const activeElement = menu.current?.ownerDocument.activeElement;
|
|
177
|
+
const menuContainsFocus = activeElement instanceof Node && menu.current?.contains(activeElement);
|
|
178
|
+
if (focusableItems.length > 0 && (!isRoot || menuContainsFocus)) focusItem();
|
|
177
179
|
});
|
|
178
180
|
return () => cancelAnimationFrame(raf);
|
|
179
181
|
}
|
|
180
|
-
}, [
|
|
182
|
+
}, [
|
|
183
|
+
open,
|
|
184
|
+
focusableItems,
|
|
185
|
+
isRoot,
|
|
186
|
+
position
|
|
187
|
+
]);
|
|
181
188
|
(0, react.useEffect)(() => {
|
|
182
189
|
if (open) handleOpen();
|
|
183
190
|
else setPosition([-1, -1]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.105.0
|
|
4
|
+
"version": "1.105.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@babel/runtime": "^7.27.3",
|
|
55
55
|
"@carbon/feature-flags": "^1.2.0",
|
|
56
|
-
"@carbon/icons-react": "^11.78.0
|
|
57
|
-
"@carbon/layout": "^11.51.0
|
|
58
|
-
"@carbon/styles": "^1.104.0
|
|
56
|
+
"@carbon/icons-react": "^11.78.0",
|
|
57
|
+
"@carbon/layout": "^11.51.0",
|
|
58
|
+
"@carbon/styles": "^1.104.0",
|
|
59
59
|
"@carbon/utilities": "^0.18.0",
|
|
60
60
|
"@floating-ui/react": "^0.27.4",
|
|
61
61
|
"@ibm/telemetry-js": "^1.5.0",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"@babel/preset-env": "^7.27.2",
|
|
79
79
|
"@babel/preset-react": "^7.27.1",
|
|
80
80
|
"@babel/preset-typescript": "^7.27.1",
|
|
81
|
-
"@carbon/test-utils": "^10.41.0
|
|
82
|
-
"@carbon/themes": "^11.71.0
|
|
81
|
+
"@carbon/test-utils": "^10.41.0",
|
|
82
|
+
"@carbon/themes": "^11.71.0",
|
|
83
83
|
"@figma/code-connect": "^1.4.2",
|
|
84
84
|
"@stackblitz/sdk": "^1.11.0",
|
|
85
85
|
"@storybook/addon-a11y": "^9.1.8",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"**/*.scss",
|
|
126
126
|
"**/*.css"
|
|
127
127
|
],
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "937649543e9cc6af9dfb6b53a2adb76760bca986"
|
|
129
129
|
}
|