@rc-component/select 1.6.12 → 1.6.14

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.
@@ -100,7 +100,8 @@ export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
100
100
  blur: () => {
101
101
  (inputRef.current || rootRef.current).blur?.();
102
102
  },
103
- nativeElement: rootRef.current
103
+ // Use getDOM to handle nested nativeElement structure (e.g., when RootComponent is antd Input)
104
+ nativeElement: getDOM(rootRef.current)
104
105
  };
105
106
  });
106
107
 
@@ -114,13 +115,18 @@ export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
114
115
  // When icon is dynamic render, the parentNode will miss
115
116
  // so we need to mark the event directly
116
117
  event.nativeEvent._ori_target = inputDOM;
117
- if (inputDOM && event.target !== inputDOM && !inputDOM.contains(event.target)) {
118
+ const isClickOnInput = inputDOM === event.target || inputDOM?.contains(event.target);
119
+ if (inputDOM && !isClickOnInput) {
118
120
  event.preventDefault();
119
121
  }
120
122
 
121
123
  // Check if we should prevent closing when clicking on selector
122
124
  // Don't close if: open && not multiple && (combobox mode || showSearch)
123
- const shouldPreventClose = triggerOpen && !multiple && (mode === 'combobox' || showSearch);
125
+ const shouldPreventCloseOnSingle = triggerOpen && !multiple && (mode === 'combobox' || showSearch);
126
+
127
+ // Don't close if: open && multiple && click on input
128
+ const shouldPreventCloseOnMultipleInput = triggerOpen && multiple && isClickOnInput;
129
+ const shouldPreventClose = shouldPreventCloseOnSingle || shouldPreventCloseOnMultipleInput;
124
130
  if (!event.nativeEvent._select_lazy) {
125
131
  inputRef.current?.focus();
126
132
 
@@ -154,13 +160,28 @@ export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
154
160
  onInputKeyDown: onInternalInputKeyDown
155
161
  };
156
162
  if (RootComponent) {
163
+ const originProps = RootComponent.props || {};
164
+ const mergedProps = {
165
+ ...originProps,
166
+ ...domProps
167
+ };
168
+ Object.keys(originProps).forEach(key => {
169
+ const originVal = originProps[key];
170
+ const domVal = domProps[key];
171
+ if (typeof originVal === 'function' && typeof domVal === 'function') {
172
+ mergedProps[key] = (...args) => {
173
+ domVal(...args);
174
+ originVal(...args);
175
+ };
176
+ }
177
+ });
157
178
  if ( /*#__PURE__*/React.isValidElement(RootComponent)) {
158
179
  return /*#__PURE__*/React.cloneElement(RootComponent, {
159
- ...domProps,
180
+ ...mergedProps,
160
181
  ref: composeRef(RootComponent.ref, rootRef)
161
182
  });
162
183
  }
163
- return /*#__PURE__*/React.createElement(RootComponent, _extends({}, domProps, {
184
+ return /*#__PURE__*/React.createElement(RootComponent, _extends({}, mergedProps, {
164
185
  ref: rootRef
165
186
  }));
166
187
  }
@@ -109,7 +109,8 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
109
109
  blur: () => {
110
110
  (inputRef.current || rootRef.current).blur?.();
111
111
  },
112
- nativeElement: rootRef.current
112
+ // Use getDOM to handle nested nativeElement structure (e.g., when RootComponent is antd Input)
113
+ nativeElement: (0, _findDOMNode.getDOM)(rootRef.current)
113
114
  };
114
115
  });
115
116
 
@@ -123,13 +124,18 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
123
124
  // When icon is dynamic render, the parentNode will miss
124
125
  // so we need to mark the event directly
125
126
  event.nativeEvent._ori_target = inputDOM;
126
- if (inputDOM && event.target !== inputDOM && !inputDOM.contains(event.target)) {
127
+ const isClickOnInput = inputDOM === event.target || inputDOM?.contains(event.target);
128
+ if (inputDOM && !isClickOnInput) {
127
129
  event.preventDefault();
128
130
  }
129
131
 
130
132
  // Check if we should prevent closing when clicking on selector
131
133
  // Don't close if: open && not multiple && (combobox mode || showSearch)
132
- const shouldPreventClose = triggerOpen && !multiple && (mode === 'combobox' || showSearch);
134
+ const shouldPreventCloseOnSingle = triggerOpen && !multiple && (mode === 'combobox' || showSearch);
135
+
136
+ // Don't close if: open && multiple && click on input
137
+ const shouldPreventCloseOnMultipleInput = triggerOpen && multiple && isClickOnInput;
138
+ const shouldPreventClose = shouldPreventCloseOnSingle || shouldPreventCloseOnMultipleInput;
133
139
  if (!event.nativeEvent._select_lazy) {
134
140
  inputRef.current?.focus();
135
141
 
@@ -163,13 +169,28 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
163
169
  onInputKeyDown: onInternalInputKeyDown
164
170
  };
165
171
  if (RootComponent) {
172
+ const originProps = RootComponent.props || {};
173
+ const mergedProps = {
174
+ ...originProps,
175
+ ...domProps
176
+ };
177
+ Object.keys(originProps).forEach(key => {
178
+ const originVal = originProps[key];
179
+ const domVal = domProps[key];
180
+ if (typeof originVal === 'function' && typeof domVal === 'function') {
181
+ mergedProps[key] = (...args) => {
182
+ domVal(...args);
183
+ originVal(...args);
184
+ };
185
+ }
186
+ });
166
187
  if ( /*#__PURE__*/React.isValidElement(RootComponent)) {
167
188
  return /*#__PURE__*/React.cloneElement(RootComponent, {
168
- ...domProps,
189
+ ...mergedProps,
169
190
  ref: (0, _ref.composeRef)(RootComponent.ref, rootRef)
170
191
  });
171
192
  }
172
- return /*#__PURE__*/React.createElement(RootComponent, _extends({}, domProps, {
193
+ return /*#__PURE__*/React.createElement(RootComponent, _extends({}, mergedProps, {
173
194
  ref: rootRef
174
195
  }));
175
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/select",
3
- "version": "1.6.12",
3
+ "version": "1.6.14",
4
4
  "description": "React Select",
5
5
  "engines": {
6
6
  "node": ">=8.x"