@lumx/react 4.30.0-next.4 → 4.30.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/index.d.ts CHANGED
@@ -4623,12 +4623,16 @@ interface BaseSelectTextFieldWrapperProps<O> extends Pick<BaseSelectProps<O>, 'o
4623
4623
  filter: 'auto' | 'manual' | 'off';
4624
4624
  /**
4625
4625
  * Controlled search input value.
4626
- * When provided, this value seeds (and resets) the visible search text in the input.
4627
- * Setting it to `''` (empty string) resets the input.
4626
+ * When provided, this value seeds the visible search text in the input. In multiple selection,
4627
+ * `''` resets it.
4628
+ * In single selection, `''` (empty string) keeps the input empty while the option stays selected:
4629
+ * the input shows only the text the user types. When you copy `onSearch` into this prop, pass
4630
+ * `search || undefined` so that the input shows the name of the selected option when idle.
4628
4631
  */
4629
4632
  searchInputValue?: string;
4630
4633
  /**
4631
- * Whether to show a clear button when a value is selected.
4634
+ * Whether the selection can be cleared (single selection): with a clear button, when the user
4635
+ * erases the input text, and with Escape. When `false`, the selection stays.
4632
4636
  * @default true
4633
4637
  */
4634
4638
  hasClearButton?: boolean;
package/index.js CHANGED
@@ -19979,7 +19979,9 @@ const SelectTextField$1 = props => {
19979
19979
  let displayValue;
19980
19980
  if (isMultiple || isSearching) {
19981
19981
  displayValue = searchText;
19982
- } else if (!isMultiple) {
19982
+ } else if (externalSearchValue === '') {
19983
+ displayValue = '';
19984
+ } else {
19983
19985
  displayValue = getOptionDisplayName(value, getOptionName, getOptionId);
19984
19986
  }
19985
19987
 
@@ -19988,13 +19990,15 @@ const SelectTextField$1 = props => {
19988
19990
  const next = toggleSelection(options, getOptionId, value, selectedOption.value, isMultiple);
19989
19991
  // In multi mode, `toggleSelection` skips when no option matches and returns the
19990
19992
  // unchanged current array — the onChange call is a no-op for the consumer.
19991
- onChange?.(next);
19993
+ // Escape on a closed combobox sends a clear request with an empty option id.
19994
+ const isBlockedClear = !isMultiple && !hasClearButton && selectedOption.value === '';
19995
+ if (!isBlockedClear) onChange?.(next);
19992
19996
 
19993
19997
  // Reset search state after selection.
19994
19998
  setIsSearching(false);
19995
19999
  setSearchText('');
19996
20000
  onSearch?.('');
19997
- }, [getOptionId, isMultiple, onChange, onSearch, options, value]);
20001
+ }, [getOptionId, hasClearButton, isMultiple, onChange, onSearch, options, value]);
19998
20002
 
19999
20003
  // Handle text input changes (search).
20000
20004
  const handleInputChange = useCallback(inputValue => {
@@ -20003,10 +20007,10 @@ const SelectTextField$1 = props => {
20003
20007
  onSearch?.(inputValue);
20004
20008
 
20005
20009
  // When the user clears the input (single mode only), clear the selection too.
20006
- if (!isMultiple && inputValue === '' && value !== undefined && value !== null) {
20010
+ if (!isMultiple && hasClearButton && inputValue === '' && value !== undefined && value !== null) {
20007
20011
  onChange?.(undefined);
20008
20012
  }
20009
- }, [isMultiple, onChange, onSearch, value]);
20013
+ }, [hasClearButton, isMultiple, onChange, onSearch, value]);
20010
20014
 
20011
20015
  // Handle clear button click (single mode only).
20012
20016
  const handleClear = useCallback(event => {