@rc-component/cascader 1.1.0 → 1.1.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/es/OptionList/Column.js +14 -0
- package/lib/OptionList/Column.js +14 -0
- package/package.json +1 -1
package/es/OptionList/Column.js
CHANGED
|
@@ -22,6 +22,7 @@ export default function Column({
|
|
|
22
22
|
}) {
|
|
23
23
|
const menuPrefixCls = `${prefixCls}-menu`;
|
|
24
24
|
const menuItemPrefixCls = `${prefixCls}-menu-item`;
|
|
25
|
+
const menuRef = React.useRef(null);
|
|
25
26
|
const {
|
|
26
27
|
fieldNames,
|
|
27
28
|
changeOnSelect,
|
|
@@ -69,10 +70,23 @@ export default function Column({
|
|
|
69
70
|
fullPathKey
|
|
70
71
|
};
|
|
71
72
|
}), [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]);
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
if (menuRef.current) {
|
|
75
|
+
const selector = `.${menuItemPrefixCls}-active`;
|
|
76
|
+
const activeElement = menuRef.current.querySelector(selector);
|
|
77
|
+
if (activeElement) {
|
|
78
|
+
activeElement.scrollIntoView({
|
|
79
|
+
block: 'nearest',
|
|
80
|
+
inline: 'nearest'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [activeValue, menuItemPrefixCls]);
|
|
72
85
|
|
|
73
86
|
// ============================ Render ============================
|
|
74
87
|
return /*#__PURE__*/React.createElement("ul", {
|
|
75
88
|
className: menuPrefixCls,
|
|
89
|
+
ref: menuRef,
|
|
76
90
|
role: "menu"
|
|
77
91
|
}, optionInfoList.map(({
|
|
78
92
|
disabled,
|
package/lib/OptionList/Column.js
CHANGED
|
@@ -32,6 +32,7 @@ function Column({
|
|
|
32
32
|
}) {
|
|
33
33
|
const menuPrefixCls = `${prefixCls}-menu`;
|
|
34
34
|
const menuItemPrefixCls = `${prefixCls}-menu-item`;
|
|
35
|
+
const menuRef = React.useRef(null);
|
|
35
36
|
const {
|
|
36
37
|
fieldNames,
|
|
37
38
|
changeOnSelect,
|
|
@@ -79,10 +80,23 @@ function Column({
|
|
|
79
80
|
fullPathKey
|
|
80
81
|
};
|
|
81
82
|
}), [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]);
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
if (menuRef.current) {
|
|
85
|
+
const selector = `.${menuItemPrefixCls}-active`;
|
|
86
|
+
const activeElement = menuRef.current.querySelector(selector);
|
|
87
|
+
if (activeElement) {
|
|
88
|
+
activeElement.scrollIntoView({
|
|
89
|
+
block: 'nearest',
|
|
90
|
+
inline: 'nearest'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [activeValue, menuItemPrefixCls]);
|
|
82
95
|
|
|
83
96
|
// ============================ Render ============================
|
|
84
97
|
return /*#__PURE__*/React.createElement("ul", {
|
|
85
98
|
className: menuPrefixCls,
|
|
99
|
+
ref: menuRef,
|
|
86
100
|
role: "menu"
|
|
87
101
|
}, optionInfoList.map(({
|
|
88
102
|
disabled,
|