From 487302d37419a503b4bb0dcb08cc430ba0f56c15 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 20 Oct 2026 15:00:07 +0900 Subject: [PATCH] =?UTF-8?q?261020=5F01=5FENH:=20kri-auto-complete=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EC=8B=9C=20=EC=98=B5=EC=85=98=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .agent/consumer.md | 5 +++++ .tooling/components/ui/command.tsx | 9 ++++++--- AGENTS.md | 5 +++++ README.md | 15 +++++++++++++++ package.json | 2 +- registry/components/KriAutoComplete.tsx | 5 +++++ registry/components/multi-select/MultiSelect.tsx | 2 ++ .../multi-select/MultiSelectContent.tsx | 16 +++++++++++++++- registry/components/multi-select/types.ts | 1 + 9 files changed, 55 insertions(+), 5 deletions(-) diff --git a/.agent/consumer.md b/.agent/consumer.md index f11235e..1b7be26 100644 --- a/.agent/consumer.md +++ b/.agent/consumer.md @@ -7,6 +7,11 @@ When implementing or changing frontend UI, use this order: 3. Otherwise, prefer a suitable shadcn/ui component. 4. Create a custom component only when the preceding options cannot meet the requirement safely. +### KriAutoComplete Search Scroll + +- `kri-auto-complete` exposes `resetScrollOnSearch?: boolean` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `false`, preserving existing behavior. +- When enabled, a search value change (including clearing it) resets the option list scroll to the top on the next animation frame in both `filter` and `inputOnly` modes. Async result updates alone do not trigger another reset. + ### Required Shared References Before each related task, read the current contents of every matching reference, even if it was read earlier in the session. diff --git a/.tooling/components/ui/command.tsx b/.tooling/components/ui/command.tsx index c3f455b..dcc77ac 100644 --- a/.tooling/components/ui/command.tsx +++ b/.tooling/components/ui/command.tsx @@ -1,4 +1,5 @@ import type { HTMLAttributes, InputHTMLAttributes } from "react"; +import { forwardRef } from "react"; import { cn } from "@/lib/utils"; export interface CommandProps extends HTMLAttributes { @@ -26,9 +27,11 @@ export function CommandInput({ className, onValueChange, onChange, ...props }: C ); } -export function CommandList({ className, ...props }: HTMLAttributes) { - return
; -} +export const CommandList = forwardRef>( + function CommandList({ className, ...props }, ref) { + return
; + }, +); export function CommandEmpty({ className, ...props }: HTMLAttributes) { return
; diff --git a/AGENTS.md b/AGENTS.md index 95289d6..fc30842 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -243,6 +243,11 @@ When implementing or changing frontend UI, use this order: 3. Otherwise, prefer a suitable shadcn/ui component. 4. Create a custom component only when the preceding options cannot meet the requirement safely. +### KriAutoComplete Search Scroll + +- `kri-auto-complete` exposes `resetScrollOnSearch?: boolean` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `false`, preserving existing behavior. +- When enabled, a search value change (including clearing it) resets the option list scroll to the top on the next animation frame in both `filter` and `inputOnly` modes. Async result updates alone do not trigger another reset. + ### Required Shared References Before each related task, read the current contents of every matching reference, even if it was read earlier in the session. diff --git a/README.md b/README.md index e60dca2..ad3e276 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,21 @@ npx shadcn@latest add https://ui-registry.kric.com/r/kri-layout.json npx shadcn@latest add https://ui-registry.kric.com/r/kri-dialog.json ``` +## KriAutoComplete 검색 스크롤 + +`kri-auto-complete`의 `KriSingleSelect`, `KriMultiSelect`와 내부 `MultiSelect`는 `resetScrollOnSearch?: boolean`을 지원합니다. 기본값은 `false`로 기존 동작을 유지합니다. + +`true`이면 검색어 변경(삭제 포함) 후 다음 프레임에 옵션 목록의 스크롤을 맨 위로 이동합니다. `searchMode="filter"`와 `searchMode="inputOnly"` 모두 적용되며, 비동기 결과 도착만으로 다시 초기화하지는 않습니다. + +```tsx + +``` + ## KRI Chart `kri-chart`는 `echarts`, `echarts-for-react` 기반 공통 차트 컴포넌트입니다. 내부적으로 `BaseEChart`를 사용하며, 모든 wrapper는 멀티 시리즈를 지원합니다. diff --git a/package.json b/package.json index 0630c94..3f6acc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kri-ui-registry", - "version": "0.14.0", + "version": "0.14.1", "private": true, "description": "KRI internal shadcn UI registry", "scripts": { diff --git a/registry/components/KriAutoComplete.tsx b/registry/components/KriAutoComplete.tsx index fd8380a..5212f97 100644 --- a/registry/components/KriAutoComplete.tsx +++ b/registry/components/KriAutoComplete.tsx @@ -11,6 +11,7 @@ export interface KriAutoCompleteBaseProps { items: T[] searchable?: boolean searchMode?: 'filter' | 'inputOnly' + resetScrollOnSearch?: boolean defaultSearchValue?: string onSearchValueChange?: (value: string) => void placeholder?: string @@ -56,6 +57,7 @@ export function KriMultiSelect({ onChange, searchable = true, searchMode = 'filter', + resetScrollOnSearch = false, defaultSearchValue = '', onSearchValueChange, maxCount = 1, @@ -96,6 +98,7 @@ export function KriMultiSelect({ badgeClassName={badgeClassName} searchable={searchable} searchMode={searchMode} + resetScrollOnSearch={resetScrollOnSearch} defaultSearchValue={defaultSearchValue} onSearchValueChange={onSearchValueChange} maxCount={maxCount} @@ -131,6 +134,7 @@ function KriSingleSelectInner({ onChange, searchable = true, searchMode = 'filter', + resetScrollOnSearch = false, defaultSearchValue = '', onSearchValueChange, placeholder = 'Select an option', @@ -208,6 +212,7 @@ function KriSingleSelectInner({ badgeClassName={badgeClassName} searchable={searchable} searchMode={searchMode} + resetScrollOnSearch={resetScrollOnSearch} defaultSearchValue={defaultSearchValue} onSearchValueChange={onSearchValueChange} preventDeselect={preventDeselect} diff --git a/registry/components/multi-select/MultiSelect.tsx b/registry/components/multi-select/MultiSelect.tsx index d1dcc0d..b4731d7 100644 --- a/registry/components/multi-select/MultiSelect.tsx +++ b/registry/components/multi-select/MultiSelect.tsx @@ -30,6 +30,7 @@ function MultiSelectInner( hideSelectAll = false, searchable = true, searchMode = 'filter', + resetScrollOnSearch = false, defaultSearchValue = '', onSearchValueChange, emptyIndicator = '검색 결과가 없습니다.', @@ -199,6 +200,7 @@ function MultiSelectInner( selectedValues={selectedValues} searchable={searchable} searchMode={searchMode} + resetScrollOnSearch={resetScrollOnSearch} searchValue={searchValue} onSearchValueChange={handleSearchChange} hideSelectAll={hideSelectAll} diff --git a/registry/components/multi-select/MultiSelectContent.tsx b/registry/components/multi-select/MultiSelectContent.tsx index 905f117..df0cec8 100644 --- a/registry/components/multi-select/MultiSelectContent.tsx +++ b/registry/components/multi-select/MultiSelectContent.tsx @@ -1,5 +1,6 @@ 'use client' +import * as React from 'react' import { CheckIcon } from 'lucide-react' import { Command, @@ -20,6 +21,7 @@ interface MultiSelectContentProps { searchable: boolean searchMode: 'filter' | 'inputOnly' searchValue: string + resetScrollOnSearch?: boolean onSearchValueChange: (value: string) => void hideSelectAll: boolean hideOptionCheck: boolean @@ -97,6 +99,7 @@ export function MultiSelectContent({ searchable, searchMode, searchValue, + resetScrollOnSearch = false, onSearchValueChange, hideSelectAll, hideOptionCheck, @@ -105,6 +108,17 @@ export function MultiSelectContent({ onToggleOption, onToggleAll, }: MultiSelectContentProps) { + const listRef = React.useRef(null) + + React.useEffect(() => { + if (!resetScrollOnSearch) return + + const frame = requestAnimationFrame(() => { + if (listRef.current) listRef.current.scrollTop = 0 + }) + return () => cancelAnimationFrame(frame) + }, [resetScrollOnSearch, searchValue]) + const grouped = isGroupedOptions(options) const flatOptions = grouped ? options.flatMap((group) => group.options) : options const selectableOptions = flatOptions.filter((option) => !option.disabled) @@ -119,7 +133,7 @@ export function MultiSelectContent({ placeholder="검색..." /> ) : null} - + {emptyIndicator} {selectionMode === 'multiple' && !hideSelectAll && selectableOptions.length > 0 ? ( <> diff --git a/registry/components/multi-select/types.ts b/registry/components/multi-select/types.ts index c1b7c6e..7d6abbb 100644 --- a/registry/components/multi-select/types.ts +++ b/registry/components/multi-select/types.ts @@ -64,6 +64,7 @@ export interface MultiSelectProps hideSelectAll?: boolean searchable?: boolean searchMode?: 'filter' | 'inputOnly' + resetScrollOnSearch?: boolean defaultSearchValue?: string onSearchValueChange?: (value: string) => void emptyIndicator?: React.ReactNode