Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/commandtextarea-combobox-filter-focus-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@cube-dev/ui-kit": patch
---

Fix several `CommandTextArea` issues and a related `ComboBox` filtering regression:

- **Stale virtual focus / commit**: As the typed token narrows, virtual focus now moves to the first still-visible option when the previously highlighted option is filtered out, and `Enter`/`Tab` can no longer commit a hidden command (e.g. typing `/` then `h` no longer inserts `/clear`). Visible options are derived from the component's own filtered collection instead of the ListBox state ref, which can lag by one render.
- **Conditional Hook**: `listStateRef` no longer calls `useRef` conditionally, preventing the Hook-order changes that could occur when the optional `listStateRef` prop was added or removed.
- **Stale caret after external value updates**: When the textarea value changes from outside (controlled updates, form reset, or a seeded `defaultValue`), the caret is now resynced from the DOM selection so trigger parsing uses a valid index.
- **`defaultValue` ignored**: An uncontrolled `CommandTextArea` now seeds its text (and trigger parsing) from `defaultValue`.
- **`ComboBox` filtering**: `ComboBox` again filters on `textValue` only, as documented. The shared `filterCollectionNodes` helper now matches plain-text `children`/`description` only when a component opts in via `matchExtraFields` (used by `CommandTextArea`).
2 changes: 1 addition & 1 deletion .size-limit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = [
}),
);
},
limit: '410kB',
limit: '415kB',
},
{
name: 'Tree shaking (just a Button)',
Expand Down
15 changes: 14 additions & 1 deletion src/components/content/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,19 @@ const Item = <T extends HTMLElement = HTMLDivElement>(
return children;
}, [children, highlight, highlightCaseSensitive, highlightStyles]);

// Process description with highlight if applicable
const processedDescription = useMemo(() => {
if (typeof description === 'string' && highlight) {
return highlightText(
description,
highlight,
highlightCaseSensitive,
highlightStyles,
);
}
return description;
}, [description, highlight, highlightCaseSensitive, highlightStyles]);

// Render function that creates the item element
const renderItemElement = (
tooltipTriggerProps?: HTMLAttributes<HTMLElement>,
Expand Down Expand Up @@ -985,7 +998,7 @@ const Item = <T extends HTMLElement = HTMLDivElement>(
: null}
{showDescription ? (
<div data-element="Description" {...descriptionProps}>
{description}
{processedDescription}
</div>
) : null}
{finalSuffix && <div data-element="Suffix">{finalSuffix}</div>}
Expand Down
Loading
Loading