refactor: remove slice and add scroll

This commit is contained in:
2026-07-24 18:51:00 +03:30
parent 30e8b82d13
commit 2ad9c44124
+12 -4
View File
@@ -9,6 +9,7 @@ interface Product {
category: string; category: string;
brand: string; brand: string;
} }
function generate5kMockProducts(): Product[] { function generate5kMockProducts(): Product[] {
const categories = [ const categories = [
"Electronics", "Electronics",
@@ -57,12 +58,19 @@ export default function CmdkTestDemo() {
onOpenChange={() => setOpened(false)} onOpenChange={() => setOpened(false)}
label="Global Command Menu" label="Global Command Menu"
> >
<Command.Input placeholder="Search Tab ..." autoFocus /> <Command.Input placeholder="Search Tab ..." autoFocus></Command.Input>
<Command.List
<Command.List> style={{
minHeight: "100px",
maxHeight: "400px",
height: "var(--cmdk-list-height)",
overflowY: "auto",
transition: "height 100ms ease",
}}
>
<Command.Empty>No results found.</Command.Empty> <Command.Empty>No results found.</Command.Empty>
<Command.Group> <Command.Group>
{actions.slice(0, 50).map((action) => ( {actions.map((action) => (
<Command.Item <Command.Item
key={action.id} key={action.id}
value={`${action.label} ${action.description}`} value={`${action.label} ${action.description}`}