@rc-component/select 1.6.1 → 1.6.3
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/BaseSelect/index.js
CHANGED
|
@@ -222,8 +222,11 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
222
222
|
key
|
|
223
223
|
} = event;
|
|
224
224
|
const isEnterKey = key === 'Enter';
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
const isSpaceKey = key === ' ';
|
|
226
|
+
|
|
227
|
+
// Enter or Space opens dropdown (ARIA combobox: spacebar should open)
|
|
228
|
+
if (isEnterKey || isSpaceKey) {
|
|
229
|
+
// Do not submit form when type in the input; prevent Space from scrolling page
|
|
227
230
|
if (mode !== 'combobox') {
|
|
228
231
|
event.preventDefault();
|
|
229
232
|
}
|
|
@@ -254,7 +257,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
254
257
|
});
|
|
255
258
|
}
|
|
256
259
|
}
|
|
257
|
-
if (mergedOpen && (!isEnterKey || !keyLockRef.current)) {
|
|
260
|
+
if (mergedOpen && (!isEnterKey || !keyLockRef.current) && !isSpaceKey) {
|
|
258
261
|
// Lock the Enter key after it is pressed to avoid repeated triggering of the onChange event.
|
|
259
262
|
if (isEnterKey) {
|
|
260
263
|
keyLockRef.current = true;
|
|
@@ -81,7 +81,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
81
81
|
|
|
82
82
|
// Render
|
|
83
83
|
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
className: clsx(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, classNames?.content),
|
|
84
|
+
className: clsx(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, mergedSearchValue && `${prefixCls}-content-has-search-value`, hasOptionStyle && `${prefixCls}-content-has-option-style`, classNames?.content),
|
|
85
85
|
style: styles?.content,
|
|
86
86
|
title: hasOptionStyle ? undefined : optionTitle
|
|
87
87
|
}, renderValue, /*#__PURE__*/React.createElement(Input, _extends({
|
package/lib/BaseSelect/index.js
CHANGED
|
@@ -231,8 +231,11 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
231
231
|
key
|
|
232
232
|
} = event;
|
|
233
233
|
const isEnterKey = key === 'Enter';
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
const isSpaceKey = key === ' ';
|
|
235
|
+
|
|
236
|
+
// Enter or Space opens dropdown (ARIA combobox: spacebar should open)
|
|
237
|
+
if (isEnterKey || isSpaceKey) {
|
|
238
|
+
// Do not submit form when type in the input; prevent Space from scrolling page
|
|
236
239
|
if (mode !== 'combobox') {
|
|
237
240
|
event.preventDefault();
|
|
238
241
|
}
|
|
@@ -263,7 +266,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
263
266
|
});
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
|
-
if (mergedOpen && (!isEnterKey || !keyLockRef.current)) {
|
|
269
|
+
if (mergedOpen && (!isEnterKey || !keyLockRef.current) && !isSpaceKey) {
|
|
267
270
|
// Lock the Enter key after it is pressed to avoid repeated triggering of the onChange event.
|
|
268
271
|
if (isEnterKey) {
|
|
269
272
|
keyLockRef.current = true;
|
|
@@ -90,7 +90,7 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
90
90
|
|
|
91
91
|
// Render
|
|
92
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
-
className: (0, _clsx.clsx)(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, classNames?.content),
|
|
93
|
+
className: (0, _clsx.clsx)(`${prefixCls}-content`, displayValue && `${prefixCls}-content-has-value`, mergedSearchValue && `${prefixCls}-content-has-search-value`, hasOptionStyle && `${prefixCls}-content-has-option-style`, classNames?.content),
|
|
94
94
|
style: styles?.content,
|
|
95
95
|
title: hasOptionStyle ? undefined : optionTitle
|
|
96
96
|
}, renderValue, /*#__PURE__*/React.createElement(_Input.default, _extends({
|